[Checkins] SVN: five.pt/trunk/ Support eager loading of patched templates (via gc lookup).

Malthe Borch mborch at gmail.com
Thu Sep 23 03:20:43 EDT 2010


Log message for revision 116743:
  Support eager loading of patched templates (via gc lookup).

Changed:
  U   five.pt/trunk/CHANGES.txt
  U   five.pt/trunk/src/five/pt/__init__.py
  U   five.pt/trunk/src/five/pt/configure.zcml

-=-
Modified: five.pt/trunk/CHANGES.txt
===================================================================
--- five.pt/trunk/CHANGES.txt	2010-09-23 07:18:08 UTC (rev 116742)
+++ five.pt/trunk/CHANGES.txt	2010-09-23 07:20:43 UTC (rev 116743)
@@ -1,6 +1,10 @@
 Changelog
 =========
 
+- Added support for eager loading (environment variable
+  ``CHAMELEON_EAGER``). This flag should be passed only in development
+  mode and will reveal any templates which do not parse.
+
 1.3 - 2010-09-08
 ~~~~~~~~~~~~~~~~
 

Modified: five.pt/trunk/src/five/pt/__init__.py
===================================================================
--- five.pt/trunk/src/five/pt/__init__.py	2010-09-23 07:18:08 UTC (rev 116742)
+++ five.pt/trunk/src/five/pt/__init__.py	2010-09-23 07:20:43 UTC (rev 116743)
@@ -1 +1,18 @@
-#
+def initialize(site):
+    import patches
+    import chameleon.core.config
+
+    if chameleon.core.config.EAGER_PARSING:
+        import gc
+
+        # this only deals with the page template classes provided by
+        # Zope, as Chameleon's classes are aware of the eager parsing
+        # flag
+        from zope.pagetemplate.pagetemplatefile import PageTemplateFile
+        from five.pt.pagetemplate import BaseTemplateFile
+
+        for template in (x for x in gc.get_objects()
+                         if isinstance(x, PageTemplateFile)):
+
+            inst = BaseTemplateFile(template.filename)
+            inst.parse()

Modified: five.pt/trunk/src/five/pt/configure.zcml
===================================================================
--- five.pt/trunk/src/five/pt/configure.zcml	2010-09-23 07:18:08 UTC (rev 116742)
+++ five.pt/trunk/src/five/pt/configure.zcml	2010-09-23 07:20:43 UTC (rev 116743)
@@ -1,19 +1,22 @@
-<configure xmlns="http://namespaces.zope.org/zope">
+<configure
+    xmlns="http://namespaces.zope.org/zope"
+    xmlns:five="http://namespaces.zope.org/five">
 
+  <include package="z3c.pt" />
   <include package="five.pt" file="meta.zcml" />
-  <include package="five.pt.patches" />
-  <include package="z3c.pt" />
 
   <utility
-     name="path"
-     component=".expressions.path_translator" />
+      name="path"
+      component=".expressions.path_translator" />
 
   <utility
-     name="exists"
-     component=".expressions.exists_translator" />
+      name="exists"
+      component=".expressions.exists_translator" />
 
   <utility
-     name="provider"
-     component=".expressions.provider_translator" />
+      name="provider"
+      component=".expressions.provider_translator" />
 
+  <five:registerPackage package="." initialize=".initialize" />
+
 </configure>



More information about the checkins mailing list