Trac Notification API
(since Trac 1.1.3)
The new API keeps the
IEmailSender extension point and the
NotificationSystem component almost unchanged from the old API, but deprecates the entire
It is replaced by a new class hierarchy. An instance of such a class contains all known data about an event that requires sending notifications:
- #NotificationEvent (common properties shared among all events)
NotificationSystem gains some simple methods to process such events. Also several new extension points are introduced that allow plugins to hook into that processing.
Contains the following properties:
realm: a string of the affected resource realm (e.g.
category: a string to identify the category of event (e.g.
target: the resource model (e.g. an instance of
datetimewhen the event happened
author: the session id of the user responsible for the event
- Known values for
targetis an instance of
- Additional properties:
comment: a string containing the user's comment (or
changes: an empty dictionary for now
targetis a list of ticket ids(!)
- Additional properties:
comment: a string containing the user's comment
new_values: a dictionary with property names as keys and new property values as values.
action: a ticket action controller action
(since Trac 0.7, deprecated since Trac 1.1.3)
The original notification API consisted mainly of a class hierarchy:
Notify(abstract base class for notifications based on a plain text template)
NotifyEmail(abstract base class for notifications via plain text email)
TicketNotifyEmail(concrete class for ticket notification emails)
BatchTicketNotifyEmail(concrete class for ticket batch modification notification emails)
In any situation that required sending notifications, a new instance of such a class was created, invoked once, and discarded. When invoked the object was responsible for finding the recipients, formatting the message and sending the email, all according to various configuration options.
This API turned out to be too inflexible. There are too few extension points that would allow plugins to hook into this process. New subclasses could be defined to handle new situations, but existing code would still explicitly use the original
TicketNotifyEmail. Strong inter-dependencies between the multiple levels of inheritance also make overriding certain things unexpectedly difficult.
The only extension point was
IEmailSender, a low-level backend for sending an already finalized email. (Since Trac 0.12)
There was also a
NotificationSystem component, mainly containing the various configuration option definitions.
This API was documented in a previous version of this page.