[Checkins] SVN: five.pt/trunk/ Add somewhat evil method to hook into grok. Unfortunately grok makes it extremely hard to do this more cleanly.
Wichert Akkerman
wichert at wiggy.net
Wed Apr 14 06:06:31 EDT 2010
Log message for revision 110841:
Add somewhat evil method to hook into grok. Unfortunately grok makes it extremely hard to do this more cleanly.
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 2010-04-14 09:48:30 UTC (rev 110840)
+++ five.pt/trunk/CHANGES.txt 2010-04-14 10:06:30 UTC (rev 110841)
@@ -1,6 +1,11 @@
Changelog
=========
+?.? - unreleased
+~~~~~~~~~~~~~~~~
+
+- Basic support for five.grok templates. [wichert]
+
0.8 - 2010-01-05
~~~~~~~~~~~~~~~~
Modified: five.pt/trunk/src/five/pt/patches.py
===================================================================
--- five.pt/trunk/src/five/pt/patches.py 2010-04-14 09:48:30 UTC (rev 110840)
+++ five.pt/trunk/src/five/pt/patches.py 2010-04-14 10:06:30 UTC (rev 110841)
@@ -81,3 +81,26 @@
ZopeViewPageTemplateFile.__get__ = get_bound_template
PageTemplateFile.__call__ = call_template
PageTemplateFile.macros = property(get_macros)
+
+try:
+ from five.grok.components import ZopeTwoPageTemplate
+
+ _tpf = FiveViewPageTemplateFile(__file__)
+ class GrokViewAwarePageTemplateFile(ViewPageTemplateFile):
+ def pt_getContext(self, *args, **kw):
+ global _tpf
+ return _tpf.pt_getContext(*args, **kw)
+ def pt_render(self, namespace, **kw):
+ if "args" in namespace:
+ del namespace["args"]
+ context=namespace.pop("context")
+ request=namespace.pop("request")
+ view=namespace["view"]
+ return self.__call__(_ob=view, context=context, request=request, **namespace)
+
+ def setFromFilename(self, filename, _prefix=None):
+ self._template = GrokViewAwarePageTemplateFile(filename, _prefix)
+ ZopeTwoPageTemplate.setFromFilename = setFromFilename
+except ImportError:
+ pass
+
More information about the checkins
mailing list