[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/form/browser/ Fix a
bug in TextWidget. The method _toFieldValue didn't convert
the form request to unicode and we got not unicoded strings
back which didn't pass the validate() call in the method
getInputValue() .
Roger Ineichen
roger at projekt01.ch
Fri May 28 15:49:45 EDT 2004
Log message for revision 25098:
Fix a bug in TextWidget. The method _toFieldValue didn't convert the form request to unicode and we got not unicoded strings back which didn't pass the validate() call in the method getInputValue() .
Because of this bug there was no way to activate a utility in the utility registration.
I think there is still more work needed in the form/ widget part.
-=-
Modified: Zope3/trunk/src/zope/app/form/browser/ftests/test_textwidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/ftests/test_textwidget.py 2004-05-28 19:19:54 UTC (rev 25097)
+++ Zope3/trunk/src/zope/app/form/browser/ftests/test_textwidget.py 2004-05-28 19:49:45 UTC (rev 25098)
@@ -109,10 +109,12 @@
# submit invalud type for text line
response = self.publish('/test/edit.html', form={
'UPDATE_SUBMIT' : '',
- 'field.s1' : 'foo' }) # not unicode
+ 'field.s1' : '' }) # not unicode
self.assertEqual(response.getStatus(), 200)
- self.assert_(validationErrorExists(
+ # XXX We don't have a invalid field value
+ #since we convert the value to unicode
+ self.assert_(not validationErrorExists(
's1', 'Object is of wrong type.', response.getBody()))
@@ -144,9 +146,9 @@
# submit missing values for required field s1
response = self.publish('/test/edit.html', form={
'UPDATE_SUBMIT' : '',
- 'field.s1' : '',
- 'field.s2' : '',
- 'field.s3' : '' })
+ 'field.s1' : u'',
+ 'field.s2' : u'',
+ 'field.s3' : u'' })
self.assertEqual(response.getStatus(), 200)
# confirm error msgs
Modified: Zope3/trunk/src/zope/app/form/browser/textwidgets.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/textwidgets.py 2004-05-28 19:19:54 UTC (rev 25097)
+++ Zope3/trunk/src/zope/app/form/browser/textwidgets.py 2004-05-28 19:49:45 UTC (rev 25098)
@@ -133,7 +133,14 @@
if self.convert_missing_value and input == self._missing:
value = self.context.missing_value
else:
- value = input
+ # XXX We convert everything to unicode :-(
+ # But I see no other way for to convert the
+ # value at the moment.
+ try:
+ value = unicode(input)
+ except ValueError, v:
+ raise ConversionError("Invalid integer data", v)
+
return decode_html(value)
More information about the Zope3-Checkins
mailing list