[Zope-Checkins] SVN: Zope/trunk/ Forward port from 2.10 branch:
Philipp von Weitershausen
philikon at philikon.de
Mon Jan 8 08:25:45 EST 2007
Log message for revision 71802:
Forward port from 2.10 branch:
Log message for revision 71799:
Fixed Collector #2223: Evaluation of booleans in TALES and the 'default' variable.
That consisted of forwardporting r70918 and r71797 from the 2.9 branch and providing
a fix.
Changed:
U Zope/trunk/doc/CHANGES.txt
U Zope/trunk/lib/python/Products/PageTemplates/Expressions.py
A Zope/trunk/lib/python/Products/PageTemplates/tests/input/BooleanAttributesAndDefault.html
A Zope/trunk/lib/python/Products/PageTemplates/tests/output/BooleanAttributesAndDefault.html
U Zope/trunk/lib/python/Products/PageTemplates/tests/testHTMLTests.py
-=-
Modified: Zope/trunk/doc/CHANGES.txt
===================================================================
--- Zope/trunk/doc/CHANGES.txt 2007-01-08 13:25:10 UTC (rev 71801)
+++ Zope/trunk/doc/CHANGES.txt 2007-01-08 13:25:43 UTC (rev 71802)
@@ -8,6 +8,9 @@
Restructuring
+ - Fixed Collector #2223: Evaluation of booleans in TALES and the
+ 'default' variable.
+
- Removed deprecated support for product initialization based on
'__ac_permissions__' and 'meta_types' attributes.
Modified: Zope/trunk/lib/python/Products/PageTemplates/Expressions.py
===================================================================
--- Zope/trunk/lib/python/Products/PageTemplates/Expressions.py 2007-01-08 13:25:10 UTC (rev 71801)
+++ Zope/trunk/lib/python/Products/PageTemplates/Expressions.py 2007-01-08 13:25:43 UTC (rev 71802)
@@ -182,12 +182,20 @@
domain, msgid, mapping=mapping,
context=context, default=default)
+ def evaluateBoolean(self, expr):
+ value = self.evaluate(expr)
+ # here we override the normal Zope 3 behaviour. Zope 3
+ # doesn't care about the default in a boolean expression,
+ # while we do (Zope 2 legacy, see the
+ # BooleanAttributesAndDefault.html test case)
+ if value is self.getDefault():
+ return value
+ return bool(value)
def evaluateText(self, expr):
""" customized version in order to get rid of unicode
errors for all and ever
"""
-
text = self.evaluate(expr)
if text is self.getDefault() or text is None:
Copied: Zope/trunk/lib/python/Products/PageTemplates/tests/input/BooleanAttributesAndDefault.html (from rev 71799, Zope/branches/2.10/lib/python/Products/PageTemplates/tests/input/BooleanAttributesAndDefault.html)
Copied: Zope/trunk/lib/python/Products/PageTemplates/tests/output/BooleanAttributesAndDefault.html (from rev 71799, Zope/branches/2.10/lib/python/Products/PageTemplates/tests/output/BooleanAttributesAndDefault.html)
Modified: Zope/trunk/lib/python/Products/PageTemplates/tests/testHTMLTests.py
===================================================================
--- Zope/trunk/lib/python/Products/PageTemplates/tests/testHTMLTests.py 2007-01-08 13:25:10 UTC (rev 71801)
+++ Zope/trunk/lib/python/Products/PageTemplates/tests/testHTMLTests.py 2007-01-08 13:25:43 UTC (rev 71802)
@@ -173,6 +173,12 @@
def checkRepeatVariable(self):
self.assert_expected(self.folder.t, 'RepeatVariable.html')
+ def checkBooleanAttributesAndDefault(self):
+ # Zope 2.9 and below support the semantics that an HTML
+ # "boolean" attribute (e.g. 'selected', 'disabled', etc.) can
+ # be used together with 'default'.
+ self.assert_expected(self.folder.t, 'BooleanAttributesAndDefault.html')
+
def test_suite():
return unittest.makeSuite(HTMLTests, 'check')
More information about the Zope-Checkins
mailing list