[Checkins] SVN: Zope/branches/2.10/ Fixed Collector #2223: Evaluation of booleans in TALES and the 'default' variable.

Philipp von Weitershausen philikon at philikon.de
Mon Jan 8 08:18:21 EST 2007


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/branches/2.10/doc/CHANGES.txt
  U   Zope/branches/2.10/lib/python/Products/PageTemplates/Expressions.py
  A   Zope/branches/2.10/lib/python/Products/PageTemplates/tests/input/BooleanAttributesAndDefault.html
  A   Zope/branches/2.10/lib/python/Products/PageTemplates/tests/output/BooleanAttributesAndDefault.html
  U   Zope/branches/2.10/lib/python/Products/PageTemplates/tests/testHTMLTests.py

-=-
Modified: Zope/branches/2.10/doc/CHANGES.txt
===================================================================
--- Zope/branches/2.10/doc/CHANGES.txt	2007-01-08 13:16:22 UTC (rev 71798)
+++ Zope/branches/2.10/doc/CHANGES.txt	2007-01-08 13:18:19 UTC (rev 71799)
@@ -8,6 +8,9 @@
 
     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

Modified: Zope/branches/2.10/lib/python/Products/PageTemplates/Expressions.py
===================================================================
--- Zope/branches/2.10/lib/python/Products/PageTemplates/Expressions.py	2007-01-08 13:16:22 UTC (rev 71798)
+++ Zope/branches/2.10/lib/python/Products/PageTemplates/Expressions.py	2007-01-08 13:18:19 UTC (rev 71799)
@@ -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/branches/2.10/lib/python/Products/PageTemplates/tests/input/BooleanAttributesAndDefault.html (from rev 71797, Zope/branches/2.9/lib/python/Products/PageTemplates/tests/input/BooleanAttributesAndDefault.html)

Copied: Zope/branches/2.10/lib/python/Products/PageTemplates/tests/output/BooleanAttributesAndDefault.html (from rev 71797, Zope/branches/2.9/lib/python/Products/PageTemplates/tests/output/BooleanAttributesAndDefault.html)

Modified: Zope/branches/2.10/lib/python/Products/PageTemplates/tests/testHTMLTests.py
===================================================================
--- Zope/branches/2.10/lib/python/Products/PageTemplates/tests/testHTMLTests.py	2007-01-08 13:16:22 UTC (rev 71798)
+++ Zope/branches/2.10/lib/python/Products/PageTemplates/tests/testHTMLTests.py	2007-01-08 13:18:19 UTC (rev 71799)
@@ -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 Checkins mailing list