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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Feb 9 17:22:48 CET 2010


Author: torsten
Date: 2010-02-09 17:22:46 +0100 (Tue, 09 Feb 2010)
New Revision: 1422

Modified:
   wasko/branches/2.0/waskaweb/lib/validators.py
Log:
* waskaweb/lib/validators.py (NewUserForm): Import from mpulsweb. Deleted implementation


Modified: wasko/branches/2.0/waskaweb/lib/validators.py
===================================================================
--- wasko/branches/2.0/waskaweb/lib/validators.py	2010-02-09 16:21:59 UTC (rev 1421)
+++ wasko/branches/2.0/waskaweb/lib/validators.py	2010-02-09 16:22:46 UTC (rev 1422)
@@ -32,7 +32,8 @@
 import time
 
 from mpulsweb.lib.validators import BaseFormValidator, NewPasswordForm, \
-ValidatorStateObject, EditUserGroupForm, NewUserGroupForm, EditSettingsForm
+ValidatorStateObject, EditUserGroupForm, NewUserGroupForm, EditSettingsForm, \
+NewUserForm
 
 class MyDateConverter(formencode.validators.FancyValidator):
 
@@ -50,61 +51,6 @@
         except:
             raise formencode.Invalid(self.message("wrong_format", state), value, state)
 
-class LoginCheck(formencode.validators.FancyValidator):
-
-    psql_max = 63
-    login_max = 0
-    valid_char = re.compile(r'^[a-z_0-9]+$')
-
-    messages = {
-        'too_long': u'Die Anmeldekennung darf nicht länger als %(max)i '
-                  u'Zeichen lang sein',
-        'invalid_char': u'Die Anmeldekennung darf nur Kleinbuchstaben, Zahlen oder Unterstriche enthalten',
-        'login_exists': u'Es existiert bereits ein Nutzer mit der Anmeldekennung "%(login)s".'
-        }
-
-    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.
-        user = session['USER_AUTHORIZED']
-        agency = user.getAgency()
-        prefix_str = "ka_%s_" % agency
-        prefix_length = len(prefix_str)
-        self.login_max =  self.psql_max - prefix_length
-        return value.strip()
-
-    def validate_python(self, value, state):
-        if len(value) > (self.login_max):
-            raise formencode.Invalid(self.message("too_long", state, max=self.login_max), value, state)
-        if not self.valid_char.match(value):
-            raise formencode.Invalid(self.message("invalid_char", state), value, state)
-        try:
-            conn, cur = None, None
-            loginname = "_".join(["ka", state.agency, value])
-            fields = {'login': loginname}
-            try:
-                conn = db.getConnection()
-                cur  = conn.cursor()
-                cur.execute("SELECT id FROM ka_benutzer_tbl_view WHERE login = %(login)s", fields)
-                result = cur.fetchone()
-                if result:
-                    raise formencode.Invalid(self.message("login_exists", state, login=value), value, state)
-            finally:
-                db.recycleConnection(conn, cur)
-        except StandardError, err:
-            print "Fehler beim Validieren der Anmeldekennung: %s" % err
-
-class NewUserForm(BaseFormValidator):
-    def __init__(self):
-        formencode.api.set_stdtranslation(domain="FormEncode", languages=["de"])
-
-    firstname = formencode.validators.String(not_empty=True) 
-    lastname = formencode.validators.String(not_empty=True) 
-    login = formencode.All(formencode.validators.String(not_empty=True), LoginCheck()) 
-    activated = formencode.validators.StringBoolean(if_missing=False)
-    newpass = formencode.validators.StringBoolean(if_missing=False)
-
 class EditUserForm(NewUserForm):
     login = None
 



More information about the Mpuls-commits mailing list