Notification in Trac 1.2

256 views
Skip to first unread message

Roger Oberholtzer

unread,
Jan 11, 2017, 9:08:02 AM1/11/17
to trac-...@googlegroups.com

I had been using the Announcer plugin in Trac. With a recent update to Trac 1.2, the Announcer plugin is no longer supported. The suggestion is to re-enable the Trac notifier.

Is there a good description of these parameters for Trac 1.2? They have gone missing from my .ini files as I was using the Announcer plugin.

TIA.

--
Roger Oberholtzer

RjOllos

unread,
Jan 11, 2017, 9:57:23 AM1/11/17
to Trac Users
The notifications components will be enabled if you don't explicitly disable them or a parent. Otherwise, it would be:

trac.notification.* = enabled
trac.ticket.notification.* = enabled

My suggestion though would be to just explicitly disable any components you don't want and otherwise use the "default enabled" rules for components that match trac.*

- Ryan
 

Roger Oberholtzer

unread,
Jan 11, 2017, 10:13:52 AM1/11/17
to trac-...@googlegroups.com
On Wed, Jan 11, 2017 at 3:57 PM, RjOllos <rjo...@gmail.com> wrote:
On Wednesday, January 11, 2017 at 6:08:02 AM UTC-8, Roger Oberholtzer wrote:

I had been using the Announcer plugin in Trac. With a recent update to Trac 1.2, the Announcer plugin is no longer supported. The suggestion is to re-enable the Trac notifier.

Is there a good description of these parameters for Trac 1.2? They have gone missing from my .ini files as I was using the Announcer plugin.

TIA.

--
Roger Oberholtzer

The notifications components will be enabled if you don't explicitly disable them or a parent. Otherwise, it would be:

trac.notification.* = enabled
trac.ticket.notification.* = enabled

I was thinking of things like the SMTP host, who the mail is from, and that sort of thing. I guess all that is the Announcer.

--
Roger Oberholtzer

Cooke, Mark

unread,
Jan 11, 2017, 10:43:35 AM1/11/17
to trac-...@googlegroups.com

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

Roger Oberholtzer

unread,
Jan 12, 2017, 2:32:19 AM1/12/17
to trac-...@googlegroups.com
On Wed, Jan 11, 2017 at 4:37 PM, Cooke, Mark <mark....@siemens-healthineers.com> wrote:
That was the place. I was mainly after the 1.2 docs. Which these are. Thanks!

--
Roger Oberholtzer

Mo

unread,
Jan 12, 2017, 10:05:33 AM1/12/17
to Trac Users
Am Mittwoch, 11. Januar 2017 15:08:02 UTC+1 schrieb Roger Oberholtzer:

I had been using the Announcer plugin in Trac. With a recent update to Trac 1.2, the Announcer plugin is no longer supported. The suggestion is to re-enable the Trac notifier.

Thanks for that hint. it was not clear that 1.2 does not support Announcer anymore.

I created some INotificationSubscriber and wondered why it doesn't appear in the subscription list of Announcer.
Now disabling that and enabling the trac.notification.* again, I see my custom rule in the notifications list...

Though there are still some things unclear with the new notifications.
The section [notification-subscriber] does it still exist? Documentation is unclear on https://trac.edgewall.org/wiki/TracNotification , the details hyperlink points to itself. How can I configure all those available subscribers like TicketOwnerSubscriber?
How can the administrator define the default rules, as currently I see only one default rule in the preferences:
Notify: Ticket that I'm listed in the CC field is modified

Best regards,
Mo

Peter Suter

unread,
Jan 12, 2017, 1:25:06 PM1/12/17
to trac-...@googlegroups.com
On 12.01.2017 16:05, Mo wrote:

The section [notification-subscriber] does it still exist?
Yes. By default (after trac-admin initenv) it looks like this:
[notification-subscriber]
always_notify_cc = CarbonCopySubscriber
always_notify_previous_updater = TicketPreviousUpdatersSubscriber
always_notify_updater = TicketUpdaterSubscriber


(If you upgraded an older Trac environment, it depends what [notification] options where configured at the time.)

Documentation is unclear on https://trac.edgewall.org/wiki/TracNotification , the details hyperlink points to itself.
Yes, that's indeed a bit confusing.
(I think that's  because this text is automatically inserted via [[TracIni(notification-subscriber)]] macro from: https://trac.edgewall.org/browser/trunk/trac/notification/api.py?rev=15315#L313
When looking at this text in the code there, the reference to TracNotification is maybe a little bit more useful.)


How can I configure all those available subscribers like TicketOwnerSubscriber?
How can the administrator define the default rules, as currently I see only one default rule in the preferences:
Notify: Ticket that I'm listed in the CC field is modified
You can add more default rules by adding them to [notification-subscriber].

[notification-subscriber]
always_notify_owner = TicketOwnerSubscriber



Best regards,
Peter



Mo

unread,
Jan 13, 2017, 3:40:11 AM1/13/17
to Trac Users
Am Donnerstag, 12. Januar 2017 19:25:06 UTC+1 schrieb Peter Suter:
On 12.01.2017 16:05, Mo wrote:

The section [notification-subscriber] does it still exist?
Yes. By default (after trac-admin initenv) it looks like this:
[notification-subscriber]
always_notify_cc = CarbonCopySubscriber
always_notify_previous_updater = TicketPreviousUpdatersSubscriber
always_notify_updater = TicketUpdaterSubscriber


(If you upgraded an older Trac environment, it depends what [notification] options where configured at the time.)

The section [notification-subscriber] is not documented like this. I had these options as remains, but I have a lot of remains from older versions or unused plugins, so I'm going to delete parts of the configuration that are not documented for 1.2.
Then https://trac.edgewall.org/wiki/TracNotification#notification-subscriber-section is duplicate in that wiki. This should be corrected as well as the documentation of all options for [notification-subscriber].

I see I can move some of the options I had for [announcer] to [notification]...

https://trac-hacks.org/changeset/16129 says that trunk is compatible with 1.2. This doesn't match the result of this discussion, no? Is it compatible with 1.2?

Best regards,
Mo

RjOllos

unread,
Jan 13, 2017, 10:18:42 AM1/13/17
to Trac Users
AnnouncerPlugin does not yet work with Trac 1.2. More changes are needed on the trunk, which will only be compatible with Trac 1.2.

- Ryan

Mo

unread,
Jan 16, 2017, 8:37:10 AM1/16/17
to Trac Users
Am Donnerstag, 12. Januar 2017 19:25:06 UTC+1 schrieb Peter Suter:
Yes. By default (after trac-admin initenv) it looks like this:
[notification-subscriber]
always_notify_cc = CarbonCopySubscriber
always_notify_previous_updater = TicketPreviousUpdatersSubscriber
always_notify_updater = TicketUpdaterSubscriber
...

You can add more default rules by adding them to [notification-subscriber].

[notification-subscriber]
always_notify_owner = TicketOwnerSubscriber

Which options are possible here?
 Currenty I have 

[notification-subscriber]
always_notify_owner
= TicketOwnerSubscriber                                                                                            
always_notify_cc
= CarbonCopySubscriber

always_notify_previous_updater
= TicketPreviousUpdatersSubscriber
always_notify_updater
= TicketUpdaterSubscriber

As this is not documented I need to ask some things.
Why isn't that defined like default_subscriptions=TicketOwnerSubscriber,CarbonCopySubscriber,TicketPreviousUpdatersSubscriber,TicketUpdaterSubscriber ?
What if I mix up those variables?

Best regards,
Mo

Peter Suter

unread,
Jan 16, 2017, 2:42:13 PM1/16/17
to trac-...@googlegroups.com
On 16.01.2017 14:37, Mo wrote:
Which options are possible here?
 Currenty I have 

[notification-subscriber]
always_notify_owner
= TicketOwnerSubscriber                                                                                            
always_notify_cc
= CarbonCopySubscriber
always_notify_previous_updater
= TicketPreviousUpdatersSubscriber
always_notify_updater
= TicketUpdaterSubscriber
The rule name on the left can be whatever you want. It has no meaning outside this config file.
The INotificationSubscriber name on the right must implement support for this config section to have any effect.
TicketOwnerSubscriber, TicketUpdaterSubscriber, TicketPreviousUpdatersSubscriber, TicketReporterSubscriber and CarbonCopySubscriber all implement support for the following:
The default attributes are:
* distributor: email
* priority: 100
* adverb: always
* format: text/plain
You can use the rule name to override these defaults:
[notification-subscriber]
rule_name = TicketOwnerSubscriber                                                                             
rule_name.distributor = another_distributor_transport_name
rule_name.priority = 222
rule_name.adverb = never
rule_name.format = another_format
...

The distributor must be the name of a transport implemented by an INotificationDistributor.
The priority must be some integer. Smaller values override larger ones, so if you use zero here, then users will not be able to override this rule.
The adverb can be either "always" or "never".
The format must be one of the supported format style names implemented by an INotificationFormatter for the selected transport and resource type of the subscriber.

The "TesterCustomFieldSubscriber" posted earlier implements supports for the same things.
AlwaysEmailSubscriber currently does not support this section.


As this is not documented I need to ask some things.
Why isn't that defined like default_subscriptions=TicketOwnerSubscriber,CarbonCopySubscriber,TicketPreviousUpdatersSubscriber,TicketUpdaterSubscriber ?
What if I mix up those variables?
Does the above answer these questions?


Best regards,
Peter

Mo

unread,
Jan 19, 2017, 8:38:21 AM1/19/17
to Trac Users
I have this definition now to get notifications if I'm listed in a custom field just like the Cc field.
Additionally I skip notifications if the change was done by myself. For all existing Subscribers in Trac I created alternative copies doing the same while dropping my own changes. It did not work to just overwrite the same class name to replace the existing implementations, so I just created additional subscriber classes for that.

However I would like to have a notification like this:
If I'm listed in a custom field, I like to get notifications only if this single field is changed. That means if I'm added or removed to that field, but no notification for any other changes on the ticket. What do I need to change on my implementation?

class TesterCustomFieldSubscriber(Component):
   
"""Subscriber for custom ticket field."""

   
implements(INotificationSubscriber)
   
    field_name
= 'tester'

   
def matches(self, event):
   
if event.realm != 'ticket':
       
return
   
if event.category not in ('created', 'changed', 'attachment added',
                 
'attachment deleted'):
       
return

   
# Custom field with comma-separated string. Parse to set.
    chrome
= Chrome(self.env)
    to_set
= lambda field: set(chrome.cc_list(field))
    field_set
= to_set(event.target[self.field_name] or '')

   
# Harvest previous field values
   
if 'fields' in event.changes and self.field_name in event.changes['fields']:
        field_set
.update(to_set(event.changes['fields'][self.field_name]['old']))

    matcher
= RecipientMatcher(self.env)
    klass
= self.__class__.__name__
    sids
= set()
   
for field in field_set:
        recipient
= matcher.match_recipient(field)
       
if not recipient:
       
continue

        sid
, auth, addr = recipient

       
# Skip if this is my own change:
       
if sid == event.author:
       
continue

       
# Default subscription
       
for s in self.default_subscriptions():
       
yield s[0], s[1], sid, auth, addr, s[2], s[3], s[4]
       
if sid:
        sids
.add((sid, auth))

   
for s in Subscription.find_by_sids_and_class(self.env, sids, klass):
       
yield s.subscription_tuple()

   
def description(self):
    ticket_system
= TicketSystem(self.env)
    ticket_field_labels
= ticket_system.get_ticket_field_labels()
    field_label
= ticket_field_labels[self.field_name]
   
return "Ticket that I'm listed in as %s is modified by someone else. [AZ]" % field_label

   
def default_subscriptions(self):
    klass
= self.__class__.__name__
   
return NotificationSystem(self.env).default_subscriptions(klass)

   
def requires_authentication(self):
   
return True


Peter Suter

unread,
Jan 19, 2017, 1:24:52 PM1/19/17
to trac-...@googlegroups.com
On 19.01.2017 14:38, Mo wrote:
Additionally I skip notifications if the change was done by myself. For all existing Subscribers in Trac I created alternative copies doing the same while dropping my own changes.
Why don't you simply add a rule "Never notify: I update a ticket"?



no notification for any other changes on the ticket.
Does this work?

if 'fields' in event.changes and not all(self.field_name == key for key in event.changes['fields']):
    return


Mo

unread,
Jan 20, 2017, 2:21:01 AM1/20/17
to Trac Users

 Very interesting. I did not realize I can exclude notifications by adding / overlaying by another rule. Maybe I can solve both requirements by some additional rules that people can subscribe additionally if they want to get less mails.

BR, Mo

Mo

unread,
Jan 23, 2017, 5:53:21 AM1/23/17
to Trac Users
Am Donnerstag, 19. Januar 2017 19:24:52 UTC+1 schrieb Peter Suter:
On 19.01.2017 14:38, Mo wrote:
Additionally I skip notifications if the change was done by myself. For all existing Subscribers in Trac I created alternative copies doing the same while dropping my own changes.
Why don't you simply add a rule "Never notify: I update a ticket"?

Peter, can I make that system-default by adding

never_notify_updater = TicketUpdaterSubscriber
never_notify_updater
.adverb = never

or is that "never" only a string prefix in the text?
BR, Mo

Mo

unread,
Jan 23, 2017, 7:23:28 AM1/23/17
to Trac Users
Am Donnerstag, 19. Januar 2017 19:24:52 UTC+1 schrieb Peter Suter:
no notification for any other changes on the ticket.
Does this work?

if 'fields' in event.changes and not all(self.field_name == key for key in event.changes['fields']):
    return

What does that do exactly?
I like to get notifications if my name is listed in field 'developer' AND any of the fields 'developer' OR 'developer-status' has changed.

Peter Suter

unread,
Jan 23, 2017, 1:18:24 PM1/23/17
to trac-...@googlegroups.com
On 23.01.2017 11:53, Mo wrote:
Am Donnerstag, 19. Januar 2017 19:24:52 UTC+1 schrieb Peter Suter:
On 19.01.2017 14:38, Mo wrote:
Additionally I skip notifications if the change was done by myself. For all existing Subscribers in Trac I created alternative copies doing the same while dropping my own changes.
Why don't you simply add a rule "Never notify: I update a ticket"?

Peter, can I make that system-default by adding

never_notify_updater = TicketUpdaterSubscriber
never_notify_updater
.adverb = never
Yes, that's correct.

Best regards,
Peter

Peter Suter

unread,
Jan 23, 2017, 1:22:45 PM1/23/17
to trac-...@googlegroups.com
On 23.01.2017 13:23, Mo wrote:
Am Donnerstag, 19. Januar 2017 19:24:52 UTC+1 schrieb Peter Suter:
no notification for any other changes on the ticket.
Does this work?

if 'fields' in event.changes and not all(self.field_name == key for key in event.changes['fields']):
    return

What does that do exactly?
It ignores events where the change to the custom field are not the only ticket changes.


I like to get notifications if my name is listed in field 'developer' AND any of the fields 'developer' OR 'developer-status' has changed.

More like this?

if 'fields' in event.changes and not all(key in ['developer', 'developer-status'] for key in event.changes['fields']):
    return

Best regards,
Peter

ivanelson

unread,
Feb 22, 2017, 3:08:03 PM2/22/17
to Trac Users
Hi

Does the notification system already support sending emails in html?

default_email_format = text/html

Peter Suter

unread,
Feb 22, 2017, 3:26:07 PM2/22/17
to trac-...@googlegroups.com
On 22.02.2017 21:08, ivanelson wrote:
> Hi
>
> Does the notification system already support sending emails in html?

Yes, with this plugin:
https://trac-hacks.org/wiki/TracHtmlNotificationPlugin

ivanelson

unread,
Feb 23, 2017, 9:39:44 AM2/23/17
to Trac Users
My trac is 1.2.

I configured this:

[components]
trachtmlnotification. * = enabled

Then I went into Preferences -> Notifications and changed to "text/html" and saved, without errors. However, when I come back in the same "notifications", text/plain is still there.

And it does not send emails in html format.



Mo

unread,
Feb 23, 2017, 9:47:00 AM2/23/17
to Trac Users
Am Donnerstag, 23. Februar 2017 15:39:44 UTC+1
Then I went into Preferences -> Notifications and changed to "text/html" and saved, without errors. However, when I come back in the same "notifications", text/plain is still there.

And it does not send emails in html format.

This is a bug: https://groups.google.com/d/msg/trac-users/d1VfehAzsWM/yfjG3BOYEAAJ

You need to save at least one custom rule, so I usually take one of the already set and set it again.

ivanelson

unread,
Feb 23, 2017, 12:47:37 PM2/23/17
to Trac Users
I managed to save(text/html). However, it still does not send in html format.

RjOllos

unread,
Feb 23, 2017, 1:10:15 PM2/23/17
to Trac Users


On Thursday, February 23, 2017 at 9:47:37 AM UTC-8, ivanelson wrote:
I managed to save(text/html). However, it still does not send in html format.

ivanelson

unread,
Feb 23, 2017, 1:41:54 PM2/23/17
to Trac Users
The documentation is not clear.

I am currently like this:

[notification]
email_address_resolvers = SpecifiedEmailResolver,SessionEmailResolver,DefaultDomainEmailResolver
email_enabled = enabled
email_from = sist...@bb.com.br
email_from_name = It Depto .:: Ger. de Desenvolvimento ::.
email_replyto = xx...@bb.com.br, zz...@bb.com.br
email_subject_prefix = __default__
email_to = undisclosed-recipients:
mime_encoding = base64
smtp_port = 25
smtp_enabled = enabled
smtp_password = password 
smtp_server = myserver.com 
smtp_user = sist...@bb.com.br
use_public_cc = disabled
use_tls = enabled
default_format = text/html

[notification-subscriber]
always_notify_cc = CarbonCopySubscriber
always_notify_previous_updater = TicketPreviousUpdatersSubscriber
always_notify_updater = TicketUpdaterSubscriber

What is missing ? Or is it something wrong?

Peter Suter

unread,
Feb 23, 2017, 2:51:49 PM2/23/17
to trac-...@googlegroups.com
On 23.02.2017 19:41, ivanelson wrote:
> The documentation is not clear.
>
> I am currently like this:
>
> [notification]
> ...
> default_format =text/html
This option does not exist. You can delete this line.
https://trac.edgewall.org/wiki/TracIni#notification-section

> [notification-subscriber]
> always_notify_cc =CarbonCopySubscriber
> always_notify_previous_updater =TicketPreviousUpdatersSubscriber
> always_notify_updater =TicketUpdaterSubscriber
This section configures the default subscriptions.
If you have TracHtmlNotificationPlugin installed, you can add the
following lines here:
always_notify_cc.format = text/html
always_notify_previous_updater.format = text/html
always_notify_updater.format = text/html

This format will then be used for these default subscriptions.
If a user has custom rules defined that override default subscriptions,
then the user's saved format preference will be used for emails
triggered by that rule.

Peter

ivanelson

unread,
Feb 23, 2017, 3:54:34 PM2/23/17
to Trac Users
I put it in [notification]. After this came the error:

2017-02-23 17:48:43,067 Trac[mail] DEBUG: EmailDistributor has found the following formats capable of handling 'email' of 'ticket': text/html, tex
t/plain
2017-02-23 17:48:43,068 Trac[web_ui] ERROR: Failure sending notification on change to ticket #14377: ConfigurationError: Cannot find implementatio
n(s) of the <code>IEmailAddressResolver</code> interface named <code>DefaultDomainEmailResolver</code>, <code>SpecifiedEmailResolver</code>. Pleas
e check that the Component is enabled or update the option <code>[notification] email_address_resolvers</code> in trac.ini.

Here it is:

[notification]
email_address_resolvers = SpecifiedEmailResolver,SessionEmailResolver,DefaultDomainEmailResolver
email_enabled = enabled
email_from = sist...@xxx.com.br
email_from_name = xx - Depto de TI .:: Ger. de Desenvolvimento ::.
email_replyto = 

email_subject_prefix = __default__
email_to = undisclosed-recipients:
mime_encoding = base64
smtp_port = 25
smtp_enabled = enabled
smtp_password = xxx
smtp_server = xx 
smtp_user = xx...@xxxa.com.br
use_public_cc = disabled
use_tls = enabled
always_notify_cc.format = text/html
always_notify_previous_updater.format = text/html
always_notify_updater.format = text/html

[notification-subscriber]
always_notify_owner = TicketOwnerSubscriber
always_notify_cc = CarbonCopySubscriber
always_notify_previous_updater = TicketPreviousUpdatersSubscriber
always_notify_updater = TicketUpdaterSubscriber

Peter Suter

unread,
Feb 23, 2017, 4:06:46 PM2/23/17
to trac-...@googlegroups.com
On 23.02.2017 21:54, ivanelson wrote:
I put it in [notification]. After this came the error:
You should put them in the [notification-subscriber] section.

[notification-subscriber]
always_notify_owner = TicketOwnerSubscriber
always_notify_owner.format = text/html
always_notify_cc =
CarbonCopySubscriber

always_notify_cc.format = text/html
always_notify_previous_updater = TicketPreviousUpdatersSubscriber

always_notify_previous_updater.format = text/html
always_notify_updater =
TicketUpdaterSubscriber
always_notify_updater.format = text/html

2017-02-23 17:48:43,067 Trac[mail] DEBUG: EmailDistributor has found the following formats capable of handling 'email' of 'ticket': text/html, tex
t/plain
2017-02-23 17:48:43,068 Trac[web_ui] ERROR: Failure sending notification on change to ticket #14377: ConfigurationError: Cannot find implementatio
n(s) of the <code>IEmailAddressResolver</code> interface named <code>DefaultDomainEmailResolver</code>, <code>SpecifiedEmailResolver</code>. Pleas
e check that the Component is enabled or update the option <code>[notification] email_address_resolvers</code> in trac.ini.

Here it is:

[notification]
email_address_resolvers = SpecifiedEmailResolver,SessionEmailResolver,DefaultDomainEmailResolver
These  don't exist in Trac. You should just have this:
email_address_resolvers =
SessionEmailResolver



ivanelson

unread,
Feb 24, 2017, 9:00:22 AM2/24/17
to Trac Users

Hi Peter,

It worked. The "Announcer Plugin" html was more beautiful. :)

Thank you.

RjOllos

unread,
Mar 18, 2017, 2:16:43 PM3/18/17
to Trac Users


On Thursday, February 23, 2017 at 11:51:49 AM UTC-8, Peter Suter wrote:
On 23.02.2017 19:41, ivanelson wrote:
> The documentation is not clear.
>
> I am currently like this:
>
> [notification]
> ...
> default_format =text/html
This option does not exist. You can delete this line.
https://trac.edgewall.org/wiki/TracIni#notification-section

An update for those not monitoring progress towards 1.2.1. 
With recently changes you can use default_format.email = text/html. See #11928.

- Ryan

RjOllos

unread,
Feb 11, 2021, 11:07:45 PM2/11/21
to Trac Users
Reply all
Reply to author
Forward
0 new messages