[Zope-Checkins] SVN: Zope/branches/philikon-aq/lib/python/Products/Five/browser/pagetemplatefile.py Not ViewPageTemplateFile but the accessor, BoundPageTemplateFile, needs to

Philipp von Weitershausen philikon at philikon.de
Tue Aug 28 19:38:48 EDT 2007


Log message for revision 79334:
  Not ViewPageTemplateFile but the accessor, BoundPageTemplateFile, needs to 
  support the Acquisition BBB (and __parent__ in order for it to work).
  

Changed:
  U   Zope/branches/philikon-aq/lib/python/Products/Five/browser/pagetemplatefile.py

-=-
Modified: Zope/branches/philikon-aq/lib/python/Products/Five/browser/pagetemplatefile.py
===================================================================
--- Zope/branches/philikon-aq/lib/python/Products/Five/browser/pagetemplatefile.py	2007-08-28 22:33:46 UTC (rev 79333)
+++ Zope/branches/philikon-aq/lib/python/Products/Five/browser/pagetemplatefile.py	2007-08-28 23:38:48 UTC (rev 79334)
@@ -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 @@
 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 @@
                        )
         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



More information about the Zope-Checkins mailing list