2008/5/23 Farialima <[EMAIL PROTECTED]>:
>
> I'd like to create a plugin that resets a custom field of the ticket
> whenever the ticket is closed.
>
> I'm using the ITicketChangeListener.ticket_changed method like this:
>
>    def ticket_changed(self, ticket, comment, author, old_values):
>        # This line will also avoid recursion...
>        if ticket['status'] != 'closed' or ticket['effort'] == '0':
>            return
>
>        ticket['effort'] = '0'
>        ticket.save_changes(author, "reset effort to zero when
> closing")
>
>
> but when I call save_changes, I get:
>
>  Trac detected an internal error:
>  IntegrityError: columns ticket, time, field are not unique
>
> This is because the change time of my change, is the same as the
> change of the ticket that just happened - so the insert in the
> 'ticket_change' table for the comment happens at the same time as the
> first change - and SQLlite barfs.
>
> The workaround is to wait a little before saving, like this:
>  import time
>  time.sleep(1)
>
> but it's not very clean....
>
> Could this be considered as a bug ?

No, because you should be using ITicketActionController or possibly
ITicketChangeManipulator.

-- 
Evolution: Taking care of those too stupid to take care of themselves.

--~--~---------~--~----~------------~-------~--~----~
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