This was found in the TicketImportPlugin, see #10188, and took me some time to debug. The following piece of code (given an env environment):
from trac.ticket.web_ui import Ticket
from datetime import datetime
from trac.util.datefmt import utc
ticket = Ticket(env)
ticket['summary'] = 'The summary'
ticket.insert()
ticket['blockedby'] = str(ticket.id)
ticket.save_changes('someone', comment='Some comments',
when=datetime.now(utc))
will work if the MasterTicketsPlugin is not installed, but will fail if it is installed, with the following error:
ticket.save_changes('someone', 'Some comments',
when=datetime.now(utc))
File "/Users/francois/ticketimportplugin/0.11/env2.5/lib/python2.5/site-packages/Trac-0.12-py2.5.egg/trac/ticket/model.py", line 353, in save_changes
listener.ticket_changed(self, comment, author, old_values)
File "build/bdist.macosx-10.7-x86_64/egg/mastertickets/api.py", line 111, in ticket_changed
links.save(author, comment, tkt.time_changed, db)
File "build/bdist.macosx-10.7-x86_64/egg/mastertickets/model.py", line 76, in save
(n, when_ts, author, 'comment', '', '(In #%s) %s'%(self.tkt.id, comment)))
File "/Users/francois/ticketimportplugin/0.11/env2.5/lib/python2.5/site-packages/Trac-0.12-py2.5.egg/trac/db/util.py", line 65, in execute
return self.cursor.execute(sql_escape_percent(sql), args)
File "/Users/francois/ticketimportplugin/0.11/env2.5/lib/python2.5/site-packages/Trac-0.12-py2.5.egg/trac/db/sqlite_backend.py", line 79, in execute
result = PyFormatCursor.execute(self, *args)
File "/Users/francois/ticketimportplugin/0.11/env2.5/lib/python2.5/site-packages/Trac-0.12-py2.5.egg/trac/db/sqlite_backend.py", line 57, in execute
args or [])
File "/Users/francois/ticketimportplugin/0.11/env2.5/lib/python2.5/site-packages/Trac-0.12-py2.5.egg/trac/db/sqlite_backend.py", line 48, in _rollbac\
k_on_error
return function(self, *args, **kwargs)
IntegrityError: columns ticket, time, field are not unique
See browser:ticketimportplugin/0.11/talm_importer/test.py@11805#L460