Not ViewPageTemplateFile but the accessor, BoundPageTemplateFile, needs to

support the Acquisition BBB (and __parent__ in order for it to work).
parent f27f0398
......@@ -16,7 +16,7 @@
$Id$
"""
from os.path import basename
import zope.app.pagetemplate
from zope.app.pagetemplate import viewpagetemplatefile
from Acquisition import aq_get
from AccessControl import getSecurityManager
......@@ -29,8 +29,7 @@ _engine = createTrustedZopeEngine()
def getEngine():
return _engine
class ViewPageTemplateFile(zope.app.pagetemplate.ViewPageTemplateFile,
AquisitionBBB):
class ViewPageTemplateFile(viewpagetemplatefile.ViewPageTemplateFile):
def getId(self):
return basename(self.filename)
......@@ -62,5 +61,20 @@ class ViewPageTemplateFile(zope.app.pagetemplate.ViewPageTemplateFile,
)
return context
def __get__(self, instance, type):
return BoundPageTemplate(self, instance)
# When a view's template is accessed e.g. as template.view, a
# BoundPageTemplate object is retured. For BBB reasons, it needs to
# support the aq_* methods and attributes known from Acquisition. For
# that it also needs to be locatable thru __parent__.
class BoundPageTemplate(viewpagetemplatefile.BoundPageTemplate,
AquisitionBBB):
__parent__ = property(lambda self: self.im_self)
# BBB
ZopeTwoPageTemplateFile = ViewPageTemplateFile
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