[Mpuls-commits] r1337 - wasko/branches/2.0/waskaweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Feb 8 17:27:05 CET 2010


Author: torsten
Date: 2010-02-08 17:27:03 +0100 (Mon, 08 Feb 2010)
New Revision: 1337

Modified:
   wasko/branches/2.0/waskaweb/lib/validators.py
Log:
* waskaweb/lib/validators.py (BaseFormValidator): Deleted. Now
imported from mpulsweb. 
* waskaweb/lib/validators.py (NewPasswordForm): Deleted. Now imported
from mpulsweb
* waskaweb/lib/validators.py (SecurePassword): Deleted not used here
anymore.


Modified: wasko/branches/2.0/waskaweb/lib/validators.py
===================================================================
--- wasko/branches/2.0/waskaweb/lib/validators.py	2010-02-08 16:22:07 UTC (rev 1336)
+++ wasko/branches/2.0/waskaweb/lib/validators.py	2010-02-08 16:27:03 UTC (rev 1337)
@@ -31,6 +31,8 @@
 import datetime
 import time
 
+from mpulsweb.lib.validators import BaseFormValidator, NewPasswordForm
+
 class ValidatorStateObject:
 
     def __setattr__(self, key, value):
@@ -39,13 +41,6 @@
     def __getattr__(self, key):
         return self.__dict__[key]
 
-class BaseFormValidator(formencode.Schema):
-    def __init__(self):
-        formencode.api.set_stdtranslation(domain="FormEncode", languages=["de"])
-
-    allow_extra_fields = True
-    filter_extra_fields = False 
-
 class MyDateConverter(formencode.validators.FancyValidator):
 
     messages = {
@@ -110,38 +105,6 @@
 
     _from_python = _to_python
 
-class SecurePassword(formencode.validators.FancyValidator):
-
-    min = 8
-    non_letter = 2
-    non_letter_literal = "zwei" 
-    letter_regex = re.compile(r'[a-zA-Z]')
-
-    messages = {
-        'too_few': u'Ihr Passwort muss mindestens %(min)i '
-                  u'Zeichen lang sein',
-        'non_letter': u'Sie müssen mindestens %(non_letter)s '
-                     u'Nicht-Buchstaben in Ihrem Passwort verwenden.',
-        'only_ascii': u'Das Passwort darf nur aus ASCII-Zeichen bestehen.'
-        }
-
-    def _to_python(self, value, state):
-        # _to_python gets run before validate_python.  Here we
-        # strip whitespace off the password, because leading and
-        # trailing whitespace in a password is too elite.
-        return value.strip()
-
-    def validate_python(self, value, state):
-        try:
-            unicode(str(value), "ascii")
-        except (UnicodeDecodeError, UnicodeEncodeError):
-            raise formencode.Invalid(self.message("only_ascii", state), value, state)
-        if len(value) < self.min:
-            raise formencode.Invalid(self.message("too_few", state, min=self.min), value, state)
-        non_letters = self.letter_regex.sub('', value)
-        if len(non_letters) < self.non_letter:
-            raise formencode.Invalid(self.message("non_letter", state, non_letter=self.non_letter_literal), value, state)
-
 class LoginCheck(formencode.validators.FancyValidator):
 
     psql_max = 63
@@ -228,11 +191,6 @@
         except StandardError, err:
             print "Fehler beim Validieren des Gruppennamens: %s" % err
 
-class NewPasswordForm(BaseFormValidator):
-    passwd = SecurePassword()  
-    passwd2 = formencode.validators.String() 
-    chained_validators = [formencode.validators.FieldsMatch('passwd', 'passwd2')]
-
 class NewUserGroupForm(BaseFormValidator):
     name = UserGroupExistsCheck(not_empty=True) 
 



More information about the Mpuls-commits mailing list