[Checkins] SVN: Zope/branches/ajung-zpt-end-game/lib/python/Products/PageTemplates/PageTemplate.py More API BBB: Provide hook (pt_macros) for subclasses to do stuff when

Philipp von Weitershausen philikon at philikon.de
Sun May 21 11:09:42 EDT 2006


Log message for revision 68214:
  More API BBB: Provide hook (pt_macros) for subclasses to do stuff when
  macro access happens.
  

Changed:
  U   Zope/branches/ajung-zpt-end-game/lib/python/Products/PageTemplates/PageTemplate.py

-=-
Modified: Zope/branches/ajung-zpt-end-game/lib/python/Products/PageTemplates/PageTemplate.py
===================================================================
--- Zope/branches/ajung-zpt-end-game/lib/python/Products/PageTemplates/PageTemplate.py	2006-05-21 14:12:29 UTC (rev 68213)
+++ Zope/branches/ajung-zpt-end-game/lib/python/Products/PageTemplates/PageTemplate.py	2006-05-21 15:09:41 UTC (rev 68214)
@@ -17,6 +17,8 @@
 import sys
 import ExtensionClass
 import zope.pagetemplate.pagetemplate
+from zope.pagetemplate.pagetemplate import PTRuntimeError
+from zope.pagetemplate.pagetemplate import PageTemplateTracebackSupplement
 from zope.tales.expressions import SimpleModuleImporter
 from Products.PageTemplates.Expressions import getEngine
 
@@ -31,13 +33,11 @@
     "to zope.pagetemplate.pagetemplate.SimpleModuleImporter (this is a "
     "class, not an instance)."
     )
-
-import zope.deferredimport
-zope.deferredimport.deprecatedFrom(
-    "It has moved to zope.pagetemplate.pagetemplate.  This reference will "
+zope.deprecation.deprecated(
+    ('PTRuntimeError', 'PageTemplateTracebackSupplement'),
+    "Zope 2 uses the Zope 3 ZPT engine now.  The object you're importing "
+    "has moved to zope.pagetemplate.pagetemplate.  This reference will "
     "be gone in Zope 2.12.",
-    'zope.pagetemplate.pagetemplate',
-    'PTRuntimeError', 'PageTemplateTracebackSupplement'
     )
 ##############################################################################
 
@@ -65,6 +65,21 @@
             c['root'] = self
         return c
 
+    @property
+    def macros(self):
+        return self.pt_macros()
+
+    # sub classes may override this to do additional stuff for macro access
+    def pt_macros(self):
+        self._cook_check()
+        if self._v_errors:
+            __traceback_supplement__ = (PageTemplateTracebackSupplement, self, {})
+            raise PTRuntimeError, (
+                'Page Template %s has errors: %s' % (
+                self.id, self._v_errors
+                ))
+        return self._v_macros
+
     # these methods are reimplemented or duplicated here because of
     # different call signatures in the Zope 2 world
 



More information about the Checkins mailing list