# HG changeset patch # User Sylvain Thénault # Date 1252578196 -7200 # Node ID b025592ff47843ea301f4fe46ac3564e61c1a9f3 # Parent 005f745315b0ddf80cd8d16a5501ba4f0374ea44 nicer fix diff -r 005f745315b0 -r b025592ff478 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)