#13211 closed defect (cantfix)
EmailDistributor throws an error, notification is not working
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | notification | Version: | 1.4 |
Severity: | major | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
- Upgraded from Trac 1.2.5 to 1.4 using pip
- Since upgrade notifications are not working any more
Trac Log:
2019-09-21 17:11:29,918 Trac[mail] WARNING: EmailDistributor caught exception while formatting ticket to text/plain for email: <class 'trac.ticket.notification.TicketFormatter'> Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/trac/notification/mail.py", line 383, in distribute outputs[fmt] = formatter.format(transport, fmt, event) File "/usr/local/lib/python2.7/dist-packages/trac/ticket/notification.py", line 143, in format return self._format_plaintext(event) File "/usr/local/lib/python2.7/dist-packages/trac/ticket/notification.py", line 248, in _format_plaintext return self._format_body(data, 'ticket_notify_email.txt') File "/usr/local/lib/python2.7/dist-packages/trac/ticket/notification.py", line 313, in _format_body template = chrome.load_template(template_name, text=True) File "/usr/local/lib/python2.7/dist-packages/trac/web/chrome.py", line 1370, in load_template return self._load_jinja_template(filename, text) File "/usr/local/lib/python2.7/dist-packages/trac/web/chrome.py", line 1396, in _load_jinja_template return (self.jenv_text if text else self.jenv).get_template(filename) File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 830, in get_template return self._load_template(name, self.make_globals(globals)) File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 804, in _load_template template = self.loader.load(self, name, globals) File "/usr/local/lib/python2.7/dist-packages/jinja2/loaders.py", line 125, in load code = environment.compile(source, name, filename) File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 591, in compile self.handle_exception(exc_info, source_hint=source_hint) File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 780, in handle_exception reraise(exc_type, exc_value, tb) File "/var/data/trac/templates/ticket_notify_email.txt", line 4, in template pv = [(a[0].strip(), a[1].strip()) for a in [b.split(':') for b in TemplateSyntaxError: expected token ',', got 'for' 2019-09-21 17:11:29,918 Trac[mail] WARNING: EmailDistributor cannot send event 'ticket' as 'text/plain': email@abc.om
Attachments (0)
Change History (7)
comment:1 by , 5 years ago
Resolution: | → cantfix |
---|---|
Status: | new → closed |
comment:2 by , 5 years ago
Looks like we might need to update the example in the documentation: 1.3/TracNotification. And also mention the need to adapt Email templates in 1.3/TracUpgrade.
follow-up: 4 comment:3 by , 5 years ago
I have almost the same error and i have updated e-mail template like you said, plus cookbook for outlook. Even without part for outlook have the same error.
2020-03-31 23:28:30,154 Trac[mail] WARNING: EmailDistributor caught exception while formatting ticket to text/plain for email: <class 'trac.ticket.notification.TicketFormatter'> Traceback (most recent call last): File "D:\TRAC\python\lib\site-packages\trac\notification\mail.py", line 487, in distribute outputs[fmt] = formatter.format(transport, fmt, event) File "D:\TRAC\python\lib\site-packages\trac\ticket\notification.py", line 143, in format return self._format_plaintext(event) File "D:\TRAC\python\lib\site-packages\trac\ticket\notification.py", line 248, in _format_plaintext return self._format_body(data, 'ticket_notify_email.txt') File "D:\TRAC\python\lib\site-packages\trac\ticket\notification.py", line 313, in _format_body template = chrome.load_template(template_name, text=True) File "D:\TRAC\python\lib\site-packages\trac\web\chrome.py", line 1370, in load_template return self._load_jinja_template(filename, text) File "D:\TRAC\python\lib\site-packages\trac\web\chrome.py", line 1396, in _load_jinja_template return (self.jenv_text if text else self.jenv).get_template(filename) File "D:\TRAC\python\lib\site-packages\jinja2\environment.py", line 883, in get_template return self._load_template(name, self.make_globals(globals)) File "D:\TRAC\python\lib\site-packages\jinja2\environment.py", line 857, in _load_template template = self.loader.load(self, name, globals) File "D:\TRAC\python\lib\site-packages\jinja2\loaders.py", line 129, in load code = environment.compile(source, name, filename) File "D:\TRAC\python\lib\site-packages\jinja2\environment.py", line 638, in compile self.handle_exception(source=source_hint) File "D:\TRAC\python\lib\site-packages\jinja2\environment.py", line 832, in handle_exception reraise(*rewrite_traceback_stack(source=source)) File "d:\trac stack projects\apic\templates\ticket_notify_email.txt", line 12, in template {% choose ticket.new %}\ TemplateSyntaxError: Encountered unknown tag 'choose'. 2020-03-31 23:28:30,154 Trac[mail] WARNING: EmailDistributor cannot send event 'ticket' as 'text/plain':
Template:
$ticket_body_hdr -------------------------------------------------------------------------- # set sel = ('Reporter', 'Owner', 'Type', 'Status', 'Priority', 'Milestone', 'Component', 'Severity', 'Resolution', 'Keywords') # for a in ticket_props.replace('|', '\n').splitlines()[1:-1]|map('trim'): # set a = a.split(':', 1)|map('trim')|list # if len(a) > 1 and a[0] in sel: ${'%-*s %s'|format(12, a[0] + ':', a[1])} # endif # endfor -------------------------------------------------------------------------- {% choose ticket.new %}\ {% when True %}\ $ticket.description {% end %}\ {% otherwise %}\ {% if changes_body %}\ ${_('Changes (by %(author)s):', author=change.author)} $changes_body {% end %}\ {% if changes_descr %}\ {% if not changes_body and not change.comment and change.author %}\ ${_('Description changed by %(author)s:', author=change.author)} {% end %}\ $changes_descr -- {% end %}\ {% if change.comment %}\ ${_('Comment:') if changes_body else _('Comment (by %(author)s):', author=change.author)} $change.comment {% end %}\ {% end %}\ {% end %}\ ${'-- '} ${_('Ticket URL: <%(link)s>', link=ticket.link)} $project.name <${project.url or abs_href()}> $project.descr
follow-up: 5 comment:4 by , 5 years ago
Replying to ricardopiccini@…:
File "d:\trac stack projects\apic\templates\ticket_notify_email.txt", line 12, in template {% choose ticket.new %}\ TemplateSyntaxError: Encountered unknown tag 'choose'. ^^^^^^Template:
... {% choose ticket.new %}\ ^^^^^^
Your template is invalid. Please ask on the MailingList for support questions.
follow-up: 6 comment:5 by , 5 years ago
Replying to Jun Omae:
Replying to ricardopiccini@…:
File "d:\trac stack projects\apic\templates\ticket_notify_email.txt", line 12, in template {% choose ticket.new %}\ TemplateSyntaxError: Encountered unknown tag 'choose'. ^^^^^^Template:
... {% choose ticket.new %}\ ^^^^^^Your template is invalid. Please ask on the MailingList for support questions.
Sorry for post here again, but this template is here:
TracNotification#CustomizingContent
and its complement is here:
follow-up: 7 comment:6 by , 5 years ago
Replying to anônimo:
Replying to Jun Omae:
Replying to ricardopiccini@…:
File "d:\trac stack projects\apic\templates\ticket_notify_email.txt", line 12, in template {% choose ticket.new %}\ TemplateSyntaxError: Encountered unknown tag 'choose'. ^^^^^^Template:
... {% choose ticket.new %}\ ^^^^^^Your template is invalid. Please ask on the MailingList for support questions.
Sorry for post here again, but this template is here:
TracNotification#CustomizingContent
and its complement is here:
With that comment I tried to said that I just copy the template from TracGuide. Could be just an example, but should be work.
comment:7 by , 5 years ago
Replying to ricardopiccini@…:
Sorry for post here again, but this template is here:
TracNotification#CustomizingContent
and its complement is here:
With that comment I tried to said that I just copy the template from TracGuide. Could be just an example, but should be work.
Revised in TracNotification@107.
InstallationIssue.
You've installed a customized ticket_notify_email.txt in /var/data/trac/templates, however the template file is probably a Genshi template or wrong Jinja2 template. Trac 1.4 switched from Genshi to Jinja2 template engine.
You should correct the template file.