[Checkins] SVN: z3c.pt/trunk/ Support try-except operator when 'python' is the default expression type.
Malthe Borch
mborch at gmail.com
Mon Sep 1 13:24:46 EDT 2008
Log message for revision 90662:
Support try-except operator when 'python' is the default expression type.
Changed:
U z3c.pt/trunk/CHANGES.txt
U z3c.pt/trunk/src/z3c/pt/expressions.py
-=-
Modified: z3c.pt/trunk/CHANGES.txt
===================================================================
--- z3c.pt/trunk/CHANGES.txt 2008-09-01 17:22:30 UTC (rev 90661)
+++ z3c.pt/trunk/CHANGES.txt 2008-09-01 17:24:46 UTC (rev 90662)
@@ -135,6 +135,9 @@
Bugfixes
+- Support try-except operator ('|') when 'python' is the default
+ expression type. [malthe]
+
- METAL macros should render in the template where they're
defined. [malthe]
Modified: z3c.pt/trunk/src/z3c/pt/expressions.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/expressions.py 2008-09-01 17:22:30 UTC (rev 90661)
+++ z3c.pt/trunk/src/z3c/pt/expressions.py 2008-09-01 17:24:46 UTC (rev 90662)
@@ -447,10 +447,20 @@
if expression:
left = m.start()+len(m.group('prefix'))
- exp = self.search(string[left+1:])
- right = left+2+len(exp)
- m = self.re_interpolation.search(string[:right])
+ match = string[left+1:]
+ while match:
+ try:
+ exp = self.expression(match)
+ break
+ except SyntaxError:
+ match = match[:-1]
+ else:
+ raise
+
+ string = string[:left+1+len(match)]+'}'
+ return self.re_interpolation.search(string)
+
if m is None or (expression is None and variable is None):
raise SyntaxError(
"Interpolation expressions must be of the "
More information about the Checkins
mailing list