[Zope-Checkins] SVN: Zope/branches/ajung-zpt-end-game/lib/python/Products/PageTemplates/PageTemplate.py Better BBB for Products.PageTemplate.PageTemplate: We can't just defer to

Philipp von Weitershausen philikon at philikon.de
Sun May 21 08:48:30 EDT 2006


Log message for revision 68208:
  Better BBB for Products.PageTemplate.PageTemplate: We can't just defer to
  zope.pagetemplate.pagetemplate.PageTemplate, we need to provide some Zope 2
  specifics still.  This isn't a big deal, though, the wrapper code is small.
  

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 11:58:12 UTC (rev 68207)
+++ Zope/branches/ajung-zpt-end-game/lib/python/Products/PageTemplates/PageTemplate.py	2006-05-21 12:48:29 UTC (rev 68208)
@@ -12,12 +12,54 @@
 ##############################################################################
 """Page Template module
 
-BBB 2005/05/01 -- to be removed after 12 months
-
 $Id$
 """
+import ExtensionClass
+import zope.pagetemplate.pagetemplate
+from zope.tales.expressions import SimpleModuleImporter
+from Products.PageTemplates.Expressions import getEngine
+from Products.PageTemplates.Expressions import SecureModuleImporter
+
+##############################################################################
+# BBB 2005/05/01 -- to be removed after 12 months
+_ModuleImporter = SimpleModuleImporter
+ModuleImporter = SimpleModuleImporter()
 import zope.deprecation
-zope.deprecation.moved("zope.pagetemplate.pagetemplate", "2.12")
+zope.deprecation.deprecated(
+    ('ModuleImporter', '_ModuleImporter'),
+    "Zope 2 uses the Zope 3 ZPT engine now.  ModuleImporter has moved "
+    "to zope.pagetemplate.pagetemplate.SimpleModuleImporter (this is a "
+    "class, not an instance)."
+    )
 
-from zope.tales.expressions import SimpleModuleImporter as _ModuleImporter
-ModuleImporter = _ModuleImporter()
+import zope.deferredimport
+zope.deferredimport.deprecatedFrom(
+    "It has moved to zope.pagetemplate.pagetemplate.  This reference will "
+    "be gone in Zope 2.12.",
+    'zope.pagetemplate.pagetemplate',
+    'PTRuntimeError', 'PageTemplateTracebackSupplement'
+    )
+##############################################################################
+
+class PageTemplate(ExtensionClass.Base,
+                   zope.pagetemplate.pagetemplate.PageTemplate):
+
+    def pt_getEngine(self):
+        return getEngine()
+
+    def pt_getContext(self, args=(), options={}):
+        c = super(PageTemplate, self).pt_getContext(args, options)
+        c.update({
+            'request': None,
+            'modules': SimpleModuleImporter(),
+            })
+        parent = getattr(self, 'aq_parent', None)
+        if parent is not None:
+            c['here'] = parent
+            c['context'] = parent
+            c['container'] = self.aq_inner.aq_parent
+            while parent is not None:
+                self = parent
+                parent = getattr(self, 'aq_parent', None)
+            c['root'] = self
+        return c



More information about the Zope-Checkins mailing list