by default this is not the widget responsability to turn empty string into None,
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 27 Jan 2010 09:59:13 +0100
changeset 4392 91a56a30141e
parent 4391 bd8480824e0b
child 4393 87e48fe398f1
by default this is not the widget responsability to turn empty string into None, move this behaviour to the field.
web/formfields.py
web/formwidgets.py
--- a/web/formfields.py	Wed Jan 27 09:57:53 2010 +0100
+++ b/web/formfields.py	Wed Jan 27 09:59:13 2010 +0100
@@ -359,7 +359,7 @@
         correctly typed objects, but process_for_value must return a typed value.
         Override this method to type the value if necessary
         """
-        return value
+        return value or None
 
     def process_posted(self, form):
         for field in self.actual_fields(form):
--- a/web/formwidgets.py	Wed Jan 27 09:57:53 2010 +0100
+++ b/web/formwidgets.py	Wed Jan 27 09:59:13 2010 +0100
@@ -115,7 +115,7 @@
         posted = form._cw.form
         val = posted.get(field.input_name(form, self.suffix))
         if isinstance(val, basestring):
-            val = val.strip() or None
+            val = val.strip()
         return val
 
     @deprecated('[3.6] use values_and_attributes')