[Zope3-checkins] SVN: zope.formlib/trunk/ LP #98491: don't blow up if TypeError raised during token conversion.
Tres Seaver
tseaver at palladion.com
Thu Apr 15 00:17:26 EDT 2010
Log message for revision 110933:
LP #98491: don't blow up if TypeError raised during token conversion.
Changed:
U zope.formlib/trunk/CHANGES.txt
U zope.formlib/trunk/src/zope/formlib/itemswidgets.py
U zope.formlib/trunk/src/zope/formlib/tests/test_itemswidget.py
-=-
Modified: zope.formlib/trunk/CHANGES.txt
===================================================================
--- zope.formlib/trunk/CHANGES.txt 2010-04-15 03:14:19 UTC (rev 110932)
+++ zope.formlib/trunk/CHANGES.txt 2010-04-15 04:17:26 UTC (rev 110933)
@@ -5,6 +5,7 @@
4.0.3 (unreleased)
==================
+- LP #98491: don't blow up if TypeError raised during token conversion.
4.0.2 (2010-03-07)
==================
Modified: zope.formlib/trunk/src/zope/formlib/itemswidgets.py
===================================================================
--- zope.formlib/trunk/src/zope/formlib/itemswidgets.py 2010-04-15 03:14:19 UTC (rev 110932)
+++ zope.formlib/trunk/src/zope/formlib/itemswidgets.py 2010-04-15 04:17:26 UTC (rev 110933)
@@ -154,7 +154,7 @@
if input:
try:
return self.convertTokensToValues([input])[0]
- except InvalidValue, e:
+ except (InvalidValue, TypeError), e:
raise ConversionError(_("Invalid value"), e)
else:
return self.context.missing_value
Modified: zope.formlib/trunk/src/zope/formlib/tests/test_itemswidget.py
===================================================================
--- zope.formlib/trunk/src/zope/formlib/tests/test_itemswidget.py 2010-04-15 03:14:19 UTC (rev 110932)
+++ zope.formlib/trunk/src/zope/formlib/tests/test_itemswidget.py 2010-04-15 04:17:26 UTC (rev 110933)
@@ -136,6 +136,18 @@
self.failIf(self._makeWidget().required)
+ def test_toFieldValue(self):
+ from zope.formlib.interfaces import ConversionError
+ widget = self._makeWidget()
+ self.assertEquals(
+ widget._toFieldValue(None), self._field.missing_value)
+ self.assertEquals(widget._toFieldValue('token1'), 'one')
+ self.assertRaises(
+ ConversionError, widget._toFieldValue, 'no_such_token')
+ self.assertRaises(
+ ConversionError, widget._toFieldValue, ['token1', 'token2'])
+
+
class ItemsMultiDisplayWidgetTest(ItemsWidgetBaseTest):
_widget = ItemsMultiDisplayWidget
More information about the Zope3-Checkins
mailing list