[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/form/browser/ Bugfix: sequcence input widget raises a WidgetError on display if any of the

Albertas Agejevas alga at pov.lt
Fri Mar 3 13:58:45 EST 2006


Log message for revision 65778:
  Bugfix: sequcence input widget raises a WidgetError on display if any of the
  subwidgets don't have valid data.
  
  (Committed to 3.2 branch in rev 65777).
  

Changed:
  U   Zope3/trunk/src/zope/app/form/browser/sequencewidget.py
  U   Zope3/trunk/src/zope/app/form/browser/tests/test_sequencewidget.py

-=-
Modified: Zope3/trunk/src/zope/app/form/browser/sequencewidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/sequencewidget.py	2006-03-03 18:35:58 UTC (rev 65777)
+++ Zope3/trunk/src/zope/app/form/browser/sequencewidget.py	2006-03-03 18:58:45 UTC (rev 65778)
@@ -206,7 +206,10 @@
             if remove_key in self.request.form:
                 removing.append(i)
             widget = self._getWidget(i)
-            found[i] = widget.getInputValue()
+            if widget.hasValidInput():
+                found[i] = widget.getInputValue()
+            else:
+                found[i] = None
         adding = (self.name + ".add") in self.request.form
 
         # remove the indicated indexes

Modified: Zope3/trunk/src/zope/app/form/browser/tests/test_sequencewidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/tests/test_sequencewidget.py	2006-03-03 18:35:58 UTC (rev 65777)
+++ Zope3/trunk/src/zope/app/form/browser/tests/test_sequencewidget.py	2006-03-03 18:58:45 UTC (rev 65778)
@@ -265,7 +265,22 @@
         s = widget()
         self.verifyResult(s, check_list, inorder=True)
 
+    def test_usererror(self):
+        self.field = Tuple(__name__=u'foo',
+                           value_type=TextLine(__name__='bar'))
+        request = TestRequest(form={
+            'field.foo.0.bar': u'', 'field.foo.1.bar': u'nonempty',
+            'field.foo.count': u'2'})
+        widget = TupleSequenceWidget(
+            self.field, self.field.value_type, request)
+        s = widget()
+        # Rendering a widget should not raise errors!
+        result = widget()
 
+        data = widget._generateSequence()
+        self.assertEquals(data, [None, u'nonempty'])
+
+
 class SequenceDisplayWidgetTest(
     VerifyResults, SequenceWidgetTestHelper, unittest.TestCase):
 



More information about the Zope3-Checkins mailing list