Commit 6118ff0d authored by Philipp von Weitershausen's avatar Philipp von Weitershausen

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.
parents 1c40e012 b8f178c3
......@@ -8,6 +8,9 @@ Zope Changes
Bugs fixed
- Fixed Collector #2223: Evaluation of booleans in TALES and the
'default' variable.
- Reverted backward-incompatible fix for Collector #2191.
- Fixed the creation of lib/python/Zope2/version.txt
......
......@@ -182,12 +182,20 @@ class ZopeContext(Context):
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:
......
<html>
<head></head>
<body>
<p tal:attributes="disabled python:True and default or 'disabled'"></p>
<p tal:attributes="disabled python:False and default or 'disabled'"></p>
</body>
</html>
<html>
<head></head>
<body>
<p></p>
<p disabled="disabled"></p>
</body>
</html>
......@@ -173,6 +173,12 @@ class HTMLTests(zope.component.testing.PlacelessSetup, unittest.TestCase):
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')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment