Springe zum Hauptinhalt

This is just a note to myself and to spare someone, who faces the same task, going through the Trac sources to find out how to do this:

from trac.env import open_environment
from trac.ticket.model import Ticket

# A list of email addresses or trac user names
NOTIFICATION_LIST = ['randomhacker', 'boss']

ticket = Ticket(open_environment('/path/to/trac/env'))
    component = u'My component',
    type = u'task',
    status = u'new',
    summary = u'Make the world a better place',
    reporter = u'me',
    # Set owner to default for given component
    owner = None,
    # You can use Trac wiki syntax here
    description = u"Don't ask '''me''' how to do it...",
    cc = ",".join(NOTIFICATION_LIST))
ticket_id = ticket.insert()

That’s all!

Update 2010-03-01: Naturally, after I figured this all out by myself by looking through the Trac source, I found this similar explanation on the trac wiki.