[Zope3-checkins] SVN: Zope3/trunk/ Fixed bug:

Jim Fulton jim at zope.com
Thu Dec 23 16:11:13 EST 2004


Log message for revision 28694:
  Fixed bug:
  
  - TextWidgets set the value attribute to "value" when the field
          has a missing value set and was not required and when there
          was no input.
  

Changed:
  U   Zope3/trunk/doc/CHANGES.txt
  U   Zope3/trunk/src/zope/app/form/browser/tests/test_textwidget.py
  U   Zope3/trunk/src/zope/app/form/browser/textwidgets.py

-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt	2004-12-23 21:06:23 UTC (rev 28693)
+++ Zope3/trunk/doc/CHANGES.txt	2004-12-23 21:11:12 UTC (rev 28694)
@@ -286,6 +286,10 @@
 
     Bug Fixes
 
+      - TextWidgets set the value attribute to "value" when the field
+        has a missing value set and was not required and when there
+        was no input.
+
       - Fixed a bug in the adapter registry that would prevent `dict`-derived
         utilites from being retrieved correctly.
 

Modified: Zope3/trunk/src/zope/app/form/browser/tests/test_textwidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/tests/test_textwidget.py	2004-12-23 21:06:23 UTC (rev 28693)
+++ Zope3/trunk/src/zope/app/form/browser/tests/test_textwidget.py	2004-12-23 21:11:12 UTC (rev 28694)
@@ -228,6 +228,34 @@
         self.verifyResult(self._widget(), ["14:39:01 +000"])
 
 
+def test_w_nonrequired_and_missing_value_and_no_inout():
+    """
+    There was a bug that caused the value attribute to be set to
+    'value' under these circumstances.
+    
+    >>> from zope.publisher.browser import TestRequest
+    >>> from zope.schema import TextLine
+    >>> field = TextLine(__name__='foo', title=u'on',
+    ...                  required=False, missing_value=u'')
+    >>> request = TestRequest()
+    >>> widget = TextWidget(field, request)
+
+    >>> def normalize(s):
+    ...   return '\\n  '.join(filter(None, s.split(' ')))
+
+    >>> print normalize( widget() )
+    <input
+      class="textType"
+      id="field.foo"
+      name="field.foo"
+      size="20"
+      type="text"
+      value=""
+      />
+
+
+    """
+
 def test_suite():
     return unittest.TestSuite((
         unittest.makeSuite(TextWidgetTest),

Modified: Zope3/trunk/src/zope/app/form/browser/textwidgets.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/textwidgets.py	2004-12-23 21:06:23 UTC (rev 28693)
+++ Zope3/trunk/src/zope/app/form/browser/textwidgets.py	2004-12-23 21:11:12 UTC (rev 28694)
@@ -127,7 +127,7 @@
                                  type=self.type,
                                  name=self.name,
                                  id=self.name,
-                                 value=self._getFormValue(),
+                                 value=self._getFormValue() or '',
                                  cssClass=self.cssClass,
                                  style=self.style,
                                  size=self.displayWidth,
@@ -138,7 +138,7 @@
                                  type=self.type,
                                  name=self.name,
                                  id=self.name,
-                                 value=self._getFormValue(),
+                                 value=self._getFormValue() or '',
                                  cssClass=self.cssClass,
                                  style=self.style,
                                  size=self.displayWidth,



More information about the Zope3-Checkins mailing list