On 19.06.2017 00:50, 'Brian' via Trac Development wrote:
How can I send "user defined" emails with the "new" trac.notification system? Or where can I find an example of a way to use the "new" api.

I'm trying to migrate some plugins to Trac 1.3.2 (trunk) and stumble upon the removed trac.notification NotfyEmail implementation that is deprecated for a while now.

I have searched the trac api web pages and the trac development pages where the new api is basically described. But for now I have still no idea of how I could implement a substitution for the NotifyEmail.notify() or NotifyEmail.send() functions to just send email notifications. This feature is uses in many plugins and support for those plugins will break with Trac 1.3.x (as an important example: the AccountManager <https://trac-hacks.org/wiki/AccountManagerPlugin?redirectedfrom=AccountManager> plugin).

I would like to upgrade at least our own installations of those plugins if some of you might be able to lead me in the right direction.

Cheers,
Brian

Depending on the plugin you might need the following:

1. Create a new subclass of NotificationEvent, or find an existing subclass like TicketChangeEvent that contains the information you need.

Example:
https://trac.edgewall.org/browser/trunk/trac/ticket/notification.py?rev=15805&marks=63-74#L62


2. Create a new object instance of that NotificationEvent class, and call NotificationSystem.notify().

Examples:
https://trac.edgewall.org/browser/trunk/trac/ticket/web_ui.py?rev=15943&marks=1356,1397#L1351

(Or call NotificationSystem.distribute_event() to circumvent subscribers, but this is not the preferred way. If possible just add more subscribers as needed.

Examples:
https://trac.edgewall.org/wiki/CookBook/Notification/Subscriptions
)


3. If you created a new NotificationEvent class, you also need to create a new INotificationFormatter component implementation that formats such events to emails.

Docs:
https://trac.edgewall.org/wiki/TracDev/PluginDevelopment/ExtensionPoints/trac.notification.api.INotificationFormatter

Example:
https://trac.edgewall.org/browser/trunk/trac/ticket/notification.py?rev=15805&marks=63-74#L94


The changes required for AccountManager should be discussed here:
https://trac-hacks.org/ticket/13124


Cheers,
Peter

--
You received this message because you are subscribed to the Google Groups "Trac 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to trac-dev+unsubscr...@googlegroups.com.
To post to this group, send email to trac-dev@googlegroups.com.
Visit this group at https://groups.google.com/group/trac-dev.
For more options, visit https://groups.google.com/d/optout.

Reply via email to