Thanks for the tip!  Though when I started the debug this way, I
realized that I would have to go through the entire ticket creation
process to get to the point of running the ticket object through dir()
or help().

Heh, unfortunately I'm not python-savvy enough to do that manually, so
I decided to take the lazy way out and post the problem here :)

On Jan 6, 1:17 pm, Benjamin Lau <[email protected]> wrote:
> You could look at the sources for the ticket class... And another handy
> trick is to use pythons dir() function to introspect on objects.
>
> Ex:
> print dir(ticket)
>
> Ben
> On Jan 6, 2012 1:00 PM, "Andrius Ilgunas" <[email protected]> wrote:
>
>
>
>
>
>
>
> > Hi all,
>
> > In my first attempt at writing a plugin, I came across the error:
>
> > <code>
> > AttributeError: 'Ticket' object has no attribute 'desc'
> > </code>
>
> > Background:
> > I'd like to run a script when a new ticket is created, and oddly, it
> > seems that there is no plugin already written to do that.  If there
> > is, would you kindly point me in that direction?
>
> > Otherwise, my question is:  What attributes exist for the ticket
> > object when creating a new ticket (i.e. when the ITicketChangeListener
> > is implemented?)
>
> > I'm GUESSING at the attribute names, and I got lucky that there's one
> > called "id".  So I presumed that there would also be one called
> > "[Dd]escription" or "[Dd]esc".  But apparently, none of those
> > attributes exist (yet?)
>
> > Below is what I have written so far, and it is functional (sans the
> > desc attribute.)
>
> > Any pointers to a solution would be more than helpful!
>
> > <code>
> > class TracRunOtherPlugin(Component):
> >   """ Executes a program on the host server."""
>
> >   implements(ITicketChangeListener)
>
> >   # ITicketChangeListener Interface
> >   def ticket_created(self, ticket):
> >      # Called when a ticket is created
> >      self.log.info('Ticket created: %r' % ticket)
>
> >      # Build the command string
> >      file_str='/var/www/qa/autoGenerateTest.php'
> >      args = ''.join([str(ticket.id), ' ', str(ticket.desc), ])
> >      cmd_str = ''.join([file_str, ' ', args, ])
>
> >      # Execute the command
> >      retcode = subprocess.call(cmd_str,shell=True)
>
> >      # Return an error if any
> >      if retcode !=0:
> >         sys.exit("Error while executing " + cmd_str + " Aborting")
>
> >   def ticket_changed(self, ticket, comment, author, old_values):
> >      # Called when a ticket is modified.
> >      #
> >      # `old_values` is a dictionary containing the previous values of
> > the
> >      #  fields that have changed.
> >      self.log.info('Ticket modified: %r' % ticket)
>
> >   def ticket_deleted(self, ticket):
> >      # Called when a ticket is deleted.
> >      self.log.info('Ticket deleted: %r' % ticket)
> > </code>
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Trac Development" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> >http://groups.google.com/group/trac-dev?hl=en.

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Development" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/trac-dev?hl=en.

Reply via email to