Skip to content
Advertisement

Trac API won’t send email

The Trac web application sends out emails perfectly. I even configured the Trac Html Notification plugin and that works too.

I want to use the API to update tickets and have them send out the notification as well and it is not working. I am doing something like this

from trac.core import *
from trac.env import Environment
from trac.ticket.model import Ticket

env = Environment('E:Trac/project')

tkt = Ticket(env, 383)
tkt['status'] = 'assigned'
tkt.save_changes()

Or

from trac.core import *
from trac.env import Environment
from trac.ticket.model import Ticket

env = Environment('E:Trac/project')

summary =  "Test New Ticket"
description = 'Testing new ticket'

tkt = Ticket(env)
tkt['reporter'] = 'jorozco'
tkt['owner'] = 'jorozco'
tkt['summary'] = summary
tkt['description'] = description
tkt['priority'] = 'Top'
tkt['task'] = '33'
tkt['status'] = 'new'
tkt.insert()

I am using Trac version 1.5.1 on Windows.

Thanks,
Joe

Advertisement

Answer

Notifications aren’t sent by changing a Ticket model object. Rather, you have to create a TicketChangeEvent and pass it to NotificationSystem.notify. See here.

In the future we may try to implement notification through ITicketChangeListener so that it’s invoked on changes to a ticket object, but it requires some redesign. See #13029.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement