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.
parent f13ec549
...@@ -12,12 +12,54 @@ ...@@ -12,12 +12,54 @@
############################################################################## ##############################################################################
"""Page Template module """Page Template module
BBB 2005/05/01 -- to be removed after 12 months
$Id$ $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 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)."
)
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()
from zope.tales.expressions import SimpleModuleImporter as _ModuleImporter def pt_getContext(self, args=(), options={}):
ModuleImporter = _ModuleImporter() 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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment