Rev 190: Switched supporting code, though not yet the template, to use SimpleTAL. in http://bzr.daniel-watkins.co.uk/pqm/ui

Daniel Watkins daniel at daniel-watkins.co.uk
Thu Jul 10 09:22:59 BST 2008


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

------------------------------------------------------------
revno: 190
revision-id: daniel at daniel-watkins.co.uk-20080710082146-myykuibjkretytk9
parent: daniel at daniel-watkins.co.uk-20080710081739-0q8yde3f00bp9h0j
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: ui
timestamp: Thu 2008-07-10 09:21:46 +0100
message:
  Switched supporting code, though not yet the template, to use SimpleTAL.
-------------- next part --------------
=== modified file 'pqm/ui/template.py'
--- a/pqm/ui/template.py	2008-07-10 07:42:11 +0000
+++ b/pqm/ui/template.py	2008-07-10 08:21:46 +0000
@@ -1,6 +1,6 @@
-from mako.template import Template
+from simpletal.simpleTAL import compileHTMLTemplate
 
-template = Template("""
+template = compileHTMLTemplate("""
 <%!
 import time
 

=== modified file 'pqm/ui/twistd.py'
--- a/pqm/ui/twistd.py	2008-07-10 08:17:39 +0000
+++ b/pqm/ui/twistd.py	2008-07-10 08:21:46 +0000
@@ -19,10 +19,11 @@
 import cgi
 import logging
 import os
+from StringIO import StringIO
 import sys
 import time
 
-from mako.template import Template
+from simpletal.simpleTALES import Context
 from twisted.application import internet, service
 from twisted.web import resource, server, static
 
@@ -51,11 +52,12 @@
             return self.getProjectPage(None, request).render(request)
 
     def getProjectPage(self, selected_project, request):
-        processing = self.currentlyProcessing()
-        messages = [self.getMessageDict(selected_project, m)
-                        for m in self.queue.messages]
-        text = template.render(messages=messages, processing=processing,
-                               status_text=self.queue.status_text)
+        c = Context()
+        c.addGlobal('processing', self.currentlyProcessing())
+        c.addGlobal('messages',[self.getMessageDict(selected_project, m)
+                                    for m in self.queue.messages])
+        text = StringIO()
+        template.expand(c, text)
         return static.Data(text, 'text/html')
 
     def currentlyProcessing(self):



More information about the bazaar-commits mailing list