[editcontrollers] handle_attribute: test for value presence before trying to convert it to int/float stable
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Wed, 09 Sep 2009 22:28:09 +0200
branchstable
changeset 3157 f4b94d03f86f
parent 3144 a5deac822a13
child 3160 9f75f5de2134
[editcontrollers] handle_attribute: test for value presence before trying to convert it to int/float
web/views/editcontroller.py
--- a/web/views/editcontroller.py	Wed Sep 09 17:16:13 2009 +0200
+++ b/web/views/editcontroller.py	Wed Sep 09 22:28:09 2009 +0200
@@ -194,13 +194,13 @@
         # NOTE: raising ValidationError here is not a good solution because
         #       we can't gather all errors at once. Hopefully, the new 3.6.x
         #       form handling will fix that
-        if attrtype == 'Int':
+        if value and attrtype == 'Int':
             try:
                 value = int(value)
             except ValueError:
                 raise ValidationError(entity.eid,
                                       {attr: self.req._("invalid integer value")})
-        elif attrtype == 'Float':
+        elif value and attrtype == 'Float':
             try:
                 value = float(value)
             except ValueError: