[Zope3-checkins] SVN: Zope3/branches/3.2/src/zope/app/form/browser/
Fixed a bug where rendering a SequenceWidget raised a
WidgetError if any
Albertas Agejevas
alga at pov.lt
Fri Mar 3 13:36:08 EST 2006
Log message for revision 65777:
Fixed a bug where rendering a SequenceWidget raised a WidgetError if any
subwidget didn't have valid data.
Changed:
U Zope3/branches/3.2/src/zope/app/form/browser/sequencewidget.py
U Zope3/branches/3.2/src/zope/app/form/browser/tests/test_sequencewidget.py
-=-
Modified: Zope3/branches/3.2/src/zope/app/form/browser/sequencewidget.py
===================================================================
--- Zope3/branches/3.2/src/zope/app/form/browser/sequencewidget.py 2006-03-03 18:26:11 UTC (rev 65776)
+++ Zope3/branches/3.2/src/zope/app/form/browser/sequencewidget.py 2006-03-03 18:35:58 UTC (rev 65777)
@@ -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/branches/3.2/src/zope/app/form/browser/tests/test_sequencewidget.py
===================================================================
--- Zope3/branches/3.2/src/zope/app/form/browser/tests/test_sequencewidget.py 2006-03-03 18:26:11 UTC (rev 65776)
+++ Zope3/branches/3.2/src/zope/app/form/browser/tests/test_sequencewidget.py 2006-03-03 18:35:58 UTC (rev 65777)
@@ -265,7 +265,21 @@
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