changeset 130:5b47af23547f

Add possibility for parseDate to return None, shouldn't happen since we also do client-side validation.
author Benoît Allard <benoit.allard@greenbone.net>
date Fri, 24 Oct 2014 10:52:47 +0200
parents d2588d88d47a
children 75c053bf2c3a
files farol/controller.py
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/farol/controller.py	Fri Oct 24 10:52:04 2014 +0200
+++ b/farol/controller.py	Fri Oct 24 10:52:47 2014 +0200
@@ -89,6 +89,9 @@
     except AttributeError: pass
     # Absorb AttributeError, and try to parse it a second time ...
     m = re.match('(\d{4})-(\d{2})-(\d{2})', string)
+    if m is None:
+        flash('Cannot parse date: "%s"' % string, 'warning')
+        return None
     return datetime(int(m.group(1)), int(m.group(2)), int(m.group(3)),
                     tzinfo=timezone(timedelta(hours=0, minutes=0)))
 

http://farol.wald.intevation.org