[Checkins] SVN: five.pt/trunk/ Added support for standard page templates (as opposed to view page templates).
Malthe Borch
mborch at gmail.com
Wed Feb 18 15:08:00 EST 2009
Log message for revision 96706:
Added support for standard page templates (as opposed to view page templates).
Changed:
U five.pt/trunk/CHANGES.txt
U five.pt/trunk/src/five/pt/patches.py
-=-
Modified: five.pt/trunk/CHANGES.txt
===================================================================
--- five.pt/trunk/CHANGES.txt 2009-02-18 20:07:11 UTC (rev 96705)
+++ five.pt/trunk/CHANGES.txt 2009-02-18 20:08:00 UTC (rev 96706)
@@ -1,6 +1,8 @@
Changelog
=========
+- Added patch for ``Products.PageTemplates.PageTemplateFile``. [malthe]
+
- Rework the "full namespace provided to path expression" change introduced
in 0.3. We no longer call the expensive locals() function but construct a
minimal namespace with the context and request ourselves. [hannosch]
Modified: five.pt/trunk/src/five/pt/patches.py
===================================================================
--- five.pt/trunk/src/five/pt/patches.py 2009-02-18 20:07:11 UTC (rev 96705)
+++ five.pt/trunk/src/five/pt/patches.py 2009-02-18 20:08:00 UTC (rev 96706)
@@ -11,6 +11,13 @@
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile as \
ZopeViewPageTemplateFile
+from Products.PageTemplates.PageTemplateFile import PageTemplateFile
+from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile as \
+ FiveViewPageTemplateFile
+
+from five.pt.pagetemplate import ViewPageTemplateFile
+from five.pt.pagetemplate import BaseTemplateFile
+
from Acquisition import aq_base
from Acquisition.interfaces import IAcquirer
@@ -21,7 +28,7 @@
import Acquisition
class BoundPageTemplate(BoundPageTemplate, Acquisition.Implicit):
- """Emulate a class implementing Acquisition.interfaces.IAcquirer and
+ """Implementing Acquisition.interfaces.IAcquirer and
IAcquisitionWrapper.
"""
@@ -36,11 +43,11 @@
im_self = im_self.__of__(im_self.context)
return self.im_func(im_self, *args, **kw)
-from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile as \
- FiveViewPageTemplateFile
-
-from five.pt.pagetemplate import ViewPageTemplateFile
-
+ class BaseTemplateFile(BaseTemplateFile, Acquisition.Implicit):
+ """Implement Acquisition.interfaces.IAcquirer and
+ IAcquisitionWrapper.
+ """
+
_marker = object()
def get_bound_template(self, instance, type):
@@ -53,5 +60,13 @@
return BoundPageTemplate(template, instance)
+def call_template(self, *args, **kw):
+ template = getattr(self, '_template', _marker)
+ if template is _marker:
+ self._template = template = BaseTemplateFile(self.filename)
+
+ return template.__of__(self)(self, *args, **kw)
+
FiveViewPageTemplateFile.__get__ = get_bound_template
ZopeViewPageTemplateFile.__get__ = get_bound_template
+PageTemplateFile.__call__ = call_template
More information about the Checkins
mailing list