[Checkins] SVN: megrok.chameleon/trunk/src/megrok/chameleon/components.py Support also path() and exists() expressions.
Uli Fouquet
uli at gnufix.de
Wed Feb 25 05:38:09 EST 2009
Log message for revision 97246:
Support also path() and exists() expressions.
Changed:
U megrok.chameleon/trunk/src/megrok/chameleon/components.py
-=-
Modified: megrok.chameleon/trunk/src/megrok/chameleon/components.py
===================================================================
--- megrok.chameleon/trunk/src/megrok/chameleon/components.py 2009-02-25 10:28:21 UTC (rev 97245)
+++ megrok.chameleon/trunk/src/megrok/chameleon/components.py 2009-02-25 10:38:08 UTC (rev 97246)
@@ -20,12 +20,12 @@
from grokcore.component import GlobalUtility, implements, name
from grokcore.view import interfaces
from grokcore.view.components import GrokTemplate
+from z3c.pt.pagetemplate import evaluate_exists, evaluate_path
#
# Chameleon Zope Page Templates...
#
class ChameleonPageTemplate(GrokTemplate):
- filename = None
def setFromString(self, string):
self._filename = None
@@ -37,6 +37,21 @@
self._template = PageTemplateFile(os.path.join(_prefix, filename))
return
+ def getNamespace(self, view):
+ """Extend namespace.
+
+ Beside the vars defined in standard grok templates, we inject
+ some vars and functions to be more compatible with official
+ ZPTs.
+ """
+ namespace = super(ChameleonPageTemplate, self).getNamespace(view)
+ namespace.update(dict(
+ template=self,
+ nothing=None,
+ path=evaluate_path,
+ exists=evaluate_exists))
+ return namespace
+
def render(self, view):
return self._template(**self.getNamespace(view))
More information about the Checkins
mailing list