[Checkins] SVN: z3c.viewtemplate/trunk/src/z3c/viewtemplate/zcml.py Speed up the use of view templates.

Jürgen Kartnaller juergen at kartnaller.at
Sun Oct 22 04:37:13 EDT 2006


Log message for revision 70877:
  Speed up the use of view templates.
    We to keep the template in the Macro factory otherwise the template file
    needs to be reloaded any time the macro is used. With this change the
    cache form the PageTemplateFile implementation speeds up everything.
  

Changed:
  U   z3c.viewtemplate/trunk/src/z3c/viewtemplate/zcml.py

-=-
Modified: z3c.viewtemplate/trunk/src/z3c/viewtemplate/zcml.py
===================================================================
--- z3c.viewtemplate/trunk/src/z3c/viewtemplate/zcml.py	2006-10-22 07:42:56 UTC (rev 70876)
+++ z3c.viewtemplate/trunk/src/z3c/viewtemplate/zcml.py	2006-10-22 08:37:10 UTC (rev 70877)
@@ -89,17 +89,20 @@
 
 class TemplateFactory(object):
 
+    template = None
+
     def __init__(self, filename, macro, contentType):
         self.filename = filename
         self.macro = macro
         self.contentType = contentType
 
     def __call__(self, view, request):
-        template = ViewPageTemplateFile(self.filename,
-                                        content_type=self.contentType)
+        if self.template is None:
+            self.template= ViewPageTemplateFile(self.filename,
+                                                content_type=self.contentType)
         if self.macro is None:
-            return template
-        return Macro(template, self.macro, view,
+            return self.template
+        return Macro(self.template, self.macro, view,
                      request, self.contentType)
 
 



More information about the Checkins mailing list