nicer fix stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 10 Sep 2009 12:23:16 +0200
branchstable
changeset 3164 b025592ff478
parent 3161 005f745315b0
child 3166 2413e5291e8d
child 3167 3d985c6f4d46
nicer fix
web/views/editcontroller.py
--- a/web/views/editcontroller.py	Thu Sep 10 08:02:52 2009 +0200
+++ b/web/views/editcontroller.py	Thu Sep 10 12:23:16 2009 +0200
@@ -194,19 +194,7 @@
         # 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 value and attrtype == 'Int':
-            try:
-                value = int(value)
-            except ValueError:
-                raise ValidationError(entity.eid,
-                                      {attr: self.req._("invalid integer value")})
-        elif value and attrtype == 'Float':
-            try:
-                value = float(value)
-            except ValueError:
-                raise ValidationError(entity.eid,
-                                      {attr: self.req._("invalid float value")})
-        elif attrtype == 'Boolean':
+        if attrtype == 'Boolean':
             value = bool(value)
         elif attrtype == 'Decimal':
             value = Decimal(value)
@@ -248,6 +236,18 @@
                 # no specified value, skip
                 return
         elif value is not None:
+            if attrtype == 'Int':
+                try:
+                    value = int(value)
+                except ValueError:
+                    raise ValidationError(entity.eid,
+                                          {attr: self.req._("invalid integer value")})
+            elif attrtype == 'Float':
+                try:
+                    value = float(value)
+                except ValueError:
+                    raise ValidationError(entity.eid,
+                                          {attr: self.req._("invalid float value")})
             if attrtype in ('Date', 'Datetime', 'Time'):
                 try:
                     value = self.parse_datetime(value, attrtype)