[Checkins] SVN: z3c.pt/trunk/ Fixed behavior of pipe character in Python expressions.

Malthe Borch mborch at gmail.com
Wed May 11 04:40:22 EDT 2011


Log message for revision 121653:
  Fixed behavior of pipe character in Python expressions.

Changed:
  U   z3c.pt/trunk/CHANGES.txt
  U   z3c.pt/trunk/src/z3c/pt/expressions.py
  U   z3c.pt/trunk/src/z3c/pt/pagetemplate.py
  A   z3c.pt/trunk/src/z3c/pt/tests/path.pt
  U   z3c.pt/trunk/src/z3c/pt/tests/test_templates.py

-=-
Modified: z3c.pt/trunk/CHANGES.txt
===================================================================
--- z3c.pt/trunk/CHANGES.txt	2011-05-11 08:37:38 UTC (rev 121652)
+++ z3c.pt/trunk/CHANGES.txt	2011-05-11 08:40:21 UTC (rev 121653)
@@ -1,6 +1,20 @@
 Changelog
 =========
 
+In next release...
+
+- Python-expressions are no longer TALES-expressions; previously, the
+  pipe operator would split Python expression clauses, allowing
+  fallbacks even for Python expressions, but this is not the standard
+  behavior of ZPT.
+
+- Fixed an issue where an error which occurred inside a dynamic
+  ``path`` or ``exists`` evaluation would fail to propagate due to a
+  missing remote context.
+
+- Set variables ``here`` and ``context`` to the bound instance value
+  on ``PageTemplate`` instances.
+
 2.0-rc2 (2011-03-24)
 ~~~~~~~~~~~~~~~~~~~~
 

Modified: z3c.pt/trunk/src/z3c/pt/expressions.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/expressions.py	2011-05-11 08:37:38 UTC (rev 121652)
+++ z3c.pt/trunk/src/z3c/pt/expressions.py	2011-05-11 08:40:21 UTC (rev 121653)
@@ -1,5 +1,5 @@
+import re
 import ast
-import re
 import namespaces
 import zope.event
 
@@ -17,6 +17,7 @@
 
 from chameleon.tales import PathExpr as BasePathExpr
 from chameleon.tales import ExistsExpr as BaseExistsExpr
+from chameleon.tales import PythonExpr as BasePythonExpr
 from chameleon.codegen import template
 from chameleon.astutil import load
 from chameleon.astutil import Symbol
@@ -212,3 +213,11 @@
             traverse=self.traverser,
             name=ast.Str(string),
             )
+
+
+class PythonExpr(BasePythonExpr):
+    def __init__(self, expression):
+        self.expression = expression
+
+    def __call__(self, target, engine):
+        return self.translate(self.expression, target)

Modified: z3c.pt/trunk/src/z3c/pt/pagetemplate.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/pagetemplate.py	2011-05-11 08:37:38 UTC (rev 121652)
+++ z3c.pt/trunk/src/z3c/pt/pagetemplate.py	2011-05-11 08:40:21 UTC (rev 121653)
@@ -5,7 +5,6 @@
 
 from chameleon.i18n import fast_translate
 from chameleon.zpt import template
-from chameleon.tales import PythonExpr
 from chameleon.tales import StringExpr
 from chameleon.tales import NotExpr
 from chameleon.nodes import Assignment
@@ -59,7 +58,7 @@
     registry = DummyRegistry()
 
     expression_types = {
-        'python': PythonExpr,
+        'python': expressions.PythonExpr,
         'string': StringExpr,
         'not': NotExpr,
         'exists': expressions.ExistsExpr,

Added: z3c.pt/trunk/src/z3c/pt/tests/path.pt
===================================================================
--- z3c.pt/trunk/src/z3c/pt/tests/path.pt	                        (rev 0)
+++ z3c.pt/trunk/src/z3c/pt/tests/path.pt	2011-05-11 08:40:21 UTC (rev 121653)
@@ -0,0 +1,4 @@
+<div tal:define="editor options/editor"
+     tal:condition="python: path('nocall:here/%s_wysiwyg_support|here/%s/wysiwyg_support|here/portal_skins/plone_wysiwyg/wysiwyg_support' % (editor, editor))">
+  WYSWIWYG supported.
+</div>

Modified: z3c.pt/trunk/src/z3c/pt/tests/test_templates.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/tests/test_templates.py	2011-05-11 08:37:38 UTC (rev 121652)
+++ z3c.pt/trunk/src/z3c/pt/tests/test_templates.py	2011-05-11 08:40:21 UTC (rev 121653)
@@ -29,7 +29,20 @@
         result = template(callable=dont_call)
         self.failUnless('ok' in result)
 
+    def test_path(self):
+        from z3c.pt.pagetemplate import PageTemplateFile
+        template = PageTemplateFile("path.pt")
 
+        class Context(object):
+            dummy_wysiwyg_support = True
+
+        context = Context()
+        template = template.__get__(context, Context)
+
+        result = template(editor="dummy")
+        self.failUnless("supported" in result)
+
+
 def test_suite():
     import sys
     return unittest.findTestCases(sys.modules[__name__])



More information about the checkins mailing list