[Checkins] SVN: zope.tales/branches/3.4/ Subexpressions of a 'string:' expression can be only path expressions.

Tres Seaver cvs-admin at zope.org
Wed May 23 15:19:00 UTC 2012


Log message for revision 126468:
  Subexpressions of a 'string:' expression can be only path expressions.
  
  See: https://bugs.launchpad.net/zope.tales/+bug/1002242
  
  

Changed:
  U   zope.tales/branches/3.4/CHANGES.txt
  U   zope.tales/branches/3.4/src/zope/tales/expressions.py
  U   zope.tales/branches/3.4/src/zope/tales/tests/test_expressions.py

-=-
Modified: zope.tales/branches/3.4/CHANGES.txt
===================================================================
--- zope.tales/branches/3.4/CHANGES.txt	2012-05-23 15:05:30 UTC (rev 126467)
+++ zope.tales/branches/3.4/CHANGES.txt	2012-05-23 15:18:57 UTC (rev 126468)
@@ -5,7 +5,8 @@
 3.4.1 (unreleased)
 ------------------
 
-- TBD
+- Subexpressions of a 'string:' expression can be only path expressions.
+  https://bugs.launchpad.net/zope.tales/+bug/1002242
 
 3.4.0 (2007-10-03)
 ------------------

Modified: zope.tales/branches/3.4/src/zope/tales/expressions.py
===================================================================
--- zope.tales/branches/3.4/src/zope/tales/expressions.py	2012-05-23 15:05:30 UTC (rev 126467)
+++ zope.tales/branches/3.4/src/zope/tales/expressions.py	2012-05-23 15:18:57 UTC (rev 126468)
@@ -224,7 +224,9 @@
 
 
 
-_interp = re.compile(r'\$(%(n)s)|\${(%(n)s(?:/[^}]*)*)}' % {'n': NAME_RE})
+_interp = re.compile(
+        r'\$(%(n)s)|\${(%(n)s(?:/[^}|]*)*(?:\|%(n)s(?:/[^}|]*)*)*)}'
+            % {'n': NAME_RE})
 
 class StringExpr(object):
     implements(ITALESExpression)

Modified: zope.tales/branches/3.4/src/zope/tales/tests/test_expressions.py
===================================================================
--- zope.tales/branches/3.4/src/zope/tales/tests/test_expressions.py	2012-05-23 15:05:30 UTC (rev 126467)
+++ zope.tales/branches/3.4/src/zope/tales/tests/test_expressions.py	2012-05-23 15:18:57 UTC (rev 126468)
@@ -132,11 +132,24 @@
         context=self.context
         self.assertEqual(expr(context), 'A2')
 
+    def testStringSub_w_python(self):
+        CompilerError = self.engine.getCompilerError()
+        self.assertRaises(CompilerError,
+                          self.engine.compile,
+                                'string:${python:1}')
+
     def testStringSubComplex(self):
         expr = self.engine.compile('string:a ${x/y} b ${y/z} c')
         context=self.context
         self.assertEqual(expr(context), 'a yikes b 3 c')
 
+    def testStringSubComplex_w_miss_and_python(self):
+        # See https://bugs.launchpad.net/zope.tales/+bug/1002242
+        CompilerError = self.engine.getCompilerError()
+        self.assertRaises(CompilerError,
+                          self.engine.compile,
+                            'string:${nothig/nothing|python:1}')
+
     def testPython(self):
         expr = self.engine.compile('python: 2 + 2')
         context=self.context



More information about the checkins mailing list