atom feed4 messages in com.googlegroups.trac-devRe: Not possible to save a ticket fro...
FromSent OnAttachments
FarialimaMay 22, 2008 4:03 pm 
Alec ThomasMay 22, 2008 4:36 pm 
Noah KantrowitzMay 22, 2008 4:45 pm 
FarialimaMay 23, 2008 8:56 am 
Subject:Re: Not possible to save a ticket from the ITicketChangeListener.ticket_changed method ?
From:Farialima (fari@gmail.com)
Date:May 23, 2008 8:56:11 am
List:com.googlegroups.trac-dev

Thank you. That works.

On May 22, 4:45 pm, Noah Kantrowitz <kan@rpi.edu> wrote:

Use ITicketManipulator to alter the ticket before it is saved.

--Noah

On Thu, 22 May 2008 16:03:22 -0700 (PDT)

Farialima <fari@gmail.com> wrote:

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 ?

I'm not the first one reporting this issue, see http://groups.google.com/group/trac-users/browse_thread/thread/35cf90...