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':
ticket['effort'] = '0'
ticket.save_changes(author, "reset effort to zero when
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: