Tuesday, September 18, 2012

trac-0.12.3 and HTML notifications and commit_updater

As I've written before, trac-0.12.3 still doesn't HTML notifications. Maurice found out how to work around a limitation with the commit_updater plugin here.



--- trac/ticket/notification.py    Tue Sep 18 15:08:52 2012
+++ trac/ticket/notification.py.bak    Tue Feb 28 10:06:34 2012
@@ -27,9 +27,6 @@
 from trac.util.datefmt import to_utimestamp
 from trac.util.text import obfuscate_email_address, text_width, wrap, CRLF
 from trac.util.translation import deactivate, reactivate
-from trac.web.api import Request
-from StringIO import StringIO
-import trac.perm as perm

 class TicketNotificationSystem(Component):

@@ -117,22 +114,11 @@
                                                 ticket, self.db, when=modtime):
                 if not change['permanent']: # attachment with same time...
                     continue
-                if self.req is None:
-                    self.env.log.warning("Req is None - a dummy Req is made so that wiki to html works")
-                    tracurl = self.env.base_url.replace("http://","")
-                    environ = {'REQUEST_METHOD': 'GET', 'SCRIPT_NAME': '', 'SERVER_PORT': 80, 'SERVER_NAME': tracurl,
-                               'wsgi.url_scheme': 'http', 'wsgi.input': StringIO('')}
-                    self.req = Request(environ, None)
-                    self.req.perm = perm.PermissionCache(self.env)
-                    change_data.update({
-                        'author': change['author'],
-                        'comment': wiki_to_html(change['comment'], env=self.env, req=self.req, absurls=True)
-                        })
-                else:
-                    change_data.update({
-                        'author': change['author'],
-                        'comment': wiki_to_html(change['comment'], env=self.env, req=self.req, absurls=True)
-                        })
+                change_data.update({
+                    'author': change['author'],
+                    'comment': wiki_to_html(change['comment'], env=self.env, req=self.req, absurls=True)
+
+                    })
                 link += '#comment:%s' % str(change.get('cnum', ''))
                 for field, values in change['fields'].iteritems():
                     old = values['old']
Or download the diff file from pastebin here.
That fixes the commit_updater.py for me. Thank you Maurice!

No comments: