[Mpuls-commits] r1482 - wasko/branches/2.0/mpulsweb/lib
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Feb 11 08:07:53 CET 2010
Author: torsten
Date: 2010-02-11 08:07:51 +0100 (Thu, 11 Feb 2010)
New Revision: 1482
Modified:
wasko/branches/2.0/mpulsweb/lib/validators.py
Log:
* mpulsweb/lib/validators.py (StringTooLong): Copied from waskaweb.
Modified: wasko/branches/2.0/mpulsweb/lib/validators.py
===================================================================
--- wasko/branches/2.0/mpulsweb/lib/validators.py 2010-02-11 07:01:36 UTC (rev 1481)
+++ wasko/branches/2.0/mpulsweb/lib/validators.py 2010-02-11 07:07:51 UTC (rev 1482)
@@ -25,6 +25,22 @@
allow_extra_fields = True
filter_extra_fields = False
+class StringTooLong(formencode.validators.FancyValidator):
+
+ messages = {
+ 'invalid_length': u'Bitte geben Sie einen Text mit maximal %(max)i Zeichen an.',
+ }
+
+ def __init__(self, max=80):
+ self.maxlength = max
+
+ def _to_python(self, value, state):
+ return value.strip()
+
+ def validate_python(self, value, state):
+ if not value is None and len(value) > self.maxlength:
+ raise formencode.Invalid(self.message("invalid_length", state, max=self.maxlength), value, state)
+
class DateCheck(formencode.validators.FancyValidator):
valid_date = re.compile(r'^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4}$')
More information about the Mpuls-commits
mailing list