Trac Notification Error - Template error

65 views
Skip to first unread message

Iqbal Ahmad

unread,
Apr 15, 2020, 4:35:39 PM4/15/20
to Trac Users
Hi,

 I am using the defalut template as mentioned in ticket_notify_email.txt and  also customization of email content.  My ticket_notify_email.txt looks like:

$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


And when I modify ticket I get the following error: 

2020-04-15 21:18:04,558 Trac[mail] DEBUG: EmailDistributor has found the following formats capable of handling 'email' of 'ticket': text/plain
2020-04-15 21:18:04,608 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/lib/python2.7/site-packages/trac/notification/mail.py", line 487, in distribute
    outputs[fmt] = formatter.format(transport, fmt, event)
  File "/usr/lib/python2.7/site-packages/trac/ticket/notification.py", line 143, in format
    return self._format_plaintext(event)
  File "/usr/lib/python2.7/site-packages/trac/ticket/notification.py", line 248, in _format_plaintext
    return self._format_body(data, 'ticket_notify_email.txt')
  File "/usr/lib/python2.7/site-packages/trac/ticket/notification.py", line 313, in _format_body
    template = chrome.load_template(template_name, text=True)
  File "/usr/lib/python2.7/site-packages/trac/web/chrome.py", line 1370, in load_template
    return self._load_jinja_template(filename, text)
  File "/usr/lib/python2.7/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 "/usr/lib64/python2.7/site-packages/jinja2/environment.py", line 883, in get_template
    return self._load_template(name, self.make_globals(globals))
  File "/usr/lib64/python2.7/site-packages/jinja2/environment.py", line 857, in _load_template
    template = self.loader.load(self, name, globals)
  File "/usr/lib64/python2.7/site-packages/jinja2/loaders.py", line 129, in load
    code = environment.compile(source, name, filename)
  File "/usr/lib64/python2.7/site-packages/jinja2/environment.py", line 638, in compile
    self.handle_exception(source=source_hint)
  File "/usr/lib64/python2.7/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/home/TRAC/templates/ticket_notify_email.txt", line 12, in template
    {% choose ticket.new %}\
TemplateSyntaxError: Encountered unknown tag 'choose'.
2020-04-15 21:18:04,608 Trac[mail] DEBUG: EmailDistributor is sending event as 'text/plain' to: xxxxxxx
2020-04-15 21:18:04,608 Trac[mail] WARNING: EmailDistributor cannot send event 'ticket' as 'text/plain': xxxxxxx

Can anyone please throw some error.  Thanks in advance.

My TRAC details:

PackageVersion
Trac1.4.1
Genshi0.7.3 (without speedups)
Jinja22.11.1
pysqlite2.6.0
Python2.7.5 (default, Apr 11 2018, 07:36:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
setuptools46.1.3
SQLite3.7.17
Subversion1.11.1 (r1850623)
jQuery1.12.4
jQuery UI1.12.1
jQuery Timepicker1.6.3

timingandestimationplugin1.6.0/home/TRAC/plugins/timingandestimationplugin-1.6.0-py2.7.egg
TracAccountManager0.6.dev0/usr/lib/python2.7/site-packages
TracpathTheme1.0.1/home/TRAC/plugins/TracpathTheme-1.0.1-py2.7.egg
TracWysiwyg0.12.0.7/usr/lib/python2.7/site-packages/TracWysiwyg-0.12.0.7-py2.7.egg
TracXMLRPC1.1.9.dev0/home/TRAC/plugins/TracXMLRPC-1.1.9dev-py2.7.egg



trac.ini

RjOllos

unread,
Apr 21, 2020, 3:26:09 PM4/21/20
to Trac Users
The default template has been updated (1). You can start with that, and apply the changes for Outlook (2).

Iqbal Ahmad

unread,
Apr 21, 2020, 6:31:05 PM4/21/20
to Trac Users
Hi Ryan,

  Thank you. Its working now.

Regards,
Iqbal
Reply all
Reply to author
Forward
0 new messages