raise ProcessFormError when a problem occurs during date / time parsing stable
authorAlexandre Fayolle <alexandre.fayolle@logilab.fr>
Thu, 16 Sep 2010 11:52:10 +0200
branchstable
changeset 6260 e06750b556ad
parent 6259 c3d98e4bee12
child 6261 82d3ac90e47c
raise ProcessFormError when a problem occurs during date / time parsing
web/formwidgets.py
--- a/web/formwidgets.py	Thu Sep 16 11:30:14 2010 +0200
+++ b/web/formwidgets.py	Thu Sep 16 11:52:10 2010 +0200
@@ -653,10 +653,16 @@
         timestr = req.form.get(field.input_name(form, 'time')).strip() or None
         if datestr is None:
             return None
-        date = todatetime(req.parse_datetime(datestr, 'Date'))
+        try:
+            date = todatetime(req.parse_datetime(datestr, 'Date'))
+        except ValueError, exc:
+            raise ProcessFormError(unicode(exc))
         if timestr is None:
             return date
-        time = req.parse_datetime(timestr, 'Time')
+        try:
+            time = req.parse_datetime(timestr, 'Time')
+        except ValueError, exc:
+            raise ProcessFormError(unicode(exc))
         return date.replace(hour=time.hour, minute=time.minute, second=time.second)