[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/form/browser/ deal reasonably with missing values in the basic display widget

Fred L. Drake, Jr. fdrake at gmail.com
Wed Dec 15 04:31:28 EST 2004


Log message for revision 28627:
  deal reasonably with missing values in the basic display widget

Changed:
  U   Zope3/trunk/src/zope/app/form/browser/tests/test_displaywidget.py
  U   Zope3/trunk/src/zope/app/form/browser/widget.py

-=-
Modified: Zope3/trunk/src/zope/app/form/browser/tests/test_displaywidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/tests/test_displaywidget.py	2004-12-13 00:04:16 UTC (rev 28626)
+++ Zope3/trunk/src/zope/app/form/browser/tests/test_displaywidget.py	2004-12-15 09:31:27 UTC (rev 28627)
@@ -72,6 +72,21 @@
     >>> widget.setRenderedValue(u'<Another Title>')
     >>> widget()
     u'&lt;Another Title&gt;'
+
+    When the value is the missing_value, the empty string should be
+    displayed::
+
+    >>> field = TextLine(title = u'Title',
+    ...                  __name__ = u'title',
+    ...                  required = False)
+
+    >>> field = field.bind(None)
+    >>> widget = DisplayWidget(field, TestRequest())
+    >>> widget.setRenderedValue(field.missing_value)
+
+    >>> widget()
+    ''
+    
     """
 
 

Modified: Zope3/trunk/src/zope/app/form/browser/widget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/widget.py	2004-12-13 00:04:16 UTC (rev 28626)
+++ Zope3/trunk/src/zope/app/form/browser/widget.py	2004-12-15 09:31:27 UTC (rev 28627)
@@ -392,6 +392,8 @@
 
     def __call__(self):
         if self._renderedValueSet():
+            if self._data == self.context.missing_value:
+                return ""
             return escape(self._data)
         else:
             return escape(self.context.default)



More information about the Zope3-Checkins mailing list