[Mpuls-commits] r3155 - base/trunk/mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Jul 8 15:06:15 CEST 2010


Author: torsten
Date: 2010-07-08 15:06:14 +0200 (Thu, 08 Jul 2010)
New Revision: 3155

Modified:
   base/trunk/mpulsweb/lib/validators.py
Log:
* mpulsweb/lib/validators.py (KeineAngabe): Added new validator the
	check if a value is "Keine Angabe" in choicelists


Modified: base/trunk/mpulsweb/lib/validators.py
===================================================================
--- base/trunk/mpulsweb/lib/validators.py	2010-07-07 14:43:27 UTC (rev 3154)
+++ base/trunk/mpulsweb/lib/validators.py	2010-07-08 13:06:14 UTC (rev 3155)
@@ -34,7 +34,20 @@
     allow_extra_fields = True
     filter_extra_fields = False
 
+class KeineAngabe(formencode.validators.FancyValidator):
 
+    messages = {
+        'invalid': u'"Keine Angabe" ist keine gültige Angabe.'
+        }
+
+    def _to_python(self, value, state):
+        return value.strip()
+
+    def validate_python(self, value, state):
+        if value == '-1':
+            raise formencode.Invalid(self.message("invalid", state),
+                                     value, state)
+
 class FileNotEmptyCheck(formencode.validators.FancyValidator):
 
     """Checks if the filename-field of the provided file-dict is empty.



More information about the Mpuls-commits mailing list