Rev 222: Consolidated template expansion. in http://bzr.daniel-watkins.co.uk/pqm/rss

Daniel Watkins daniel at daniel-watkins.co.uk
Mon Jul 14 15:16:23 BST 2008


At http://bzr.daniel-watkins.co.uk/pqm/rss

------------------------------------------------------------
revno: 222
revision-id: daniel at daniel-watkins.co.uk-20080714141506-10rtrhfn23aagi7k
parent: daniel at daniel-watkins.co.uk-20080714141020-oi3qsf07d0zclchl
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: rss
timestamp: Mon 2008-07-14 15:15:06 +0100
message:
  Consolidated template expansion.
-------------- next part --------------
=== modified file 'pqm/ui/twistd.py'
--- a/pqm/ui/twistd.py	2008-07-14 14:10:20 +0000
+++ b/pqm/ui/twistd.py	2008-07-14 14:15:06 +0000
@@ -59,6 +59,15 @@
 
     def getProjectPage(self, selected_project, request):
         template = compileHTMLTemplate(html_template)
+        return static.Data(self.expandTemplate(template, selected_project),
+                           'text/html')
+
+    def getProjectRSS(self, selected_project, request):
+        template = compileXMLTemplate(rss_template)
+        return static.Data(self.expandTemplate(template, selected_project),
+                           'application/xml')
+
+    def expandTemplate(self, template, selected_project):
         c = Context(allowPythonPath=True)
         c.addGlobal('processing', self.currentlyProcessing())
         c.addGlobal('messages', [self.getMessageDict(selected_project, m)
@@ -68,18 +77,7 @@
         c.addGlobal('status_text', self.queue.status_text)
         text = StringIO()
         template.expand(c, text)
-        return static.Data(text.getvalue(), 'text/html')
-
-    def getProjectRSS(self, selected_project, request):
-        template = compileXMLTemplate(rss_template)
-        c = Context()
-        c.addGlobal('processing', self.currentlyProcessing())
-        c.addGlobal('messages', [self.getMessageDict(selected_project, m)
-                                    for m in self.queue.messages])
-        c.addGlobal('status_text', self.queue.status_text)
-        text = StringIO()
-        template.expand(c, text)
-        return static.Data(text.getvalue(), 'application/xml')
+        return text.getvalue()
 
     def currentlyProcessing(self):
         configp = pqm.ConfigParser()



More information about the bazaar-commits mailing list