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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Feb 9 14:13:55 CET 2010


Author: torsten
Date: 2010-02-09 14:13:54 +0100 (Tue, 09 Feb 2010)
New Revision: 1369

Modified:
   wasko/branches/2.0/waskaweb/lib/validators.py
Log:
* waskaweb/lib/validators.py: Deleted moved Validators 


Modified: wasko/branches/2.0/waskaweb/lib/validators.py
===================================================================
--- wasko/branches/2.0/waskaweb/lib/validators.py	2010-02-09 13:12:22 UTC (rev 1368)
+++ wasko/branches/2.0/waskaweb/lib/validators.py	2010-02-09 13:13:54 UTC (rev 1369)
@@ -31,16 +31,9 @@
 import datetime
 import time
 
-from mpulsweb.lib.validators import BaseFormValidator, NewPasswordForm
+from mpulsweb.lib.validators import BaseFormValidator, NewPasswordForm, \
+ValidatorStateObject, EditUserGroupForm, NewUserGroupForm
 
-class ValidatorStateObject:
-
-    def __setattr__(self, key, value):
-        self.__dict__[key] = value
-
-    def __getattr__(self, key):
-        return self.__dict__[key]
-
 class MyDateConverter(formencode.validators.FancyValidator):
 
     messages = {
@@ -150,53 +143,6 @@
         except StandardError, err:
             print "Fehler beim Validieren der Anmeldekennung: %s" % err
 
-
-class UserGroupExistsCheck(formencode.validators.FancyValidator):
-
-    messages = {
-        'group_exists': u'Es existiert bereits eine Benutzergruppe mit dem Namen "%(name)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.
-        return value.strip()
-
-    def validate_python(self, value, state):
-        try:
-            conn, cur = None, None
-            if state:
-                fields = {'name': value, 'id': state.groupid}
-            else:
-                fields = {'name': value, 'id': None}
-            try:
-                conn = db.getConnection()
-                cur  = conn.cursor()
-                cur.execute("SELECT name FROM ka_benutzergruppe_tbl_view WHERE id = %(id)s", fields)
-                result = cur.fetchone()
-
-                if result:
-                    newname = result[0]
-                else: 
-                    newname = result
-
-                if newname != value:
-                    cur.execute("SELECT id FROM ka_benutzergruppe_tbl_view WHERE name = %(name)s", fields)
-                    result = cur.fetchone()
-                    if result:
-                        raise formencode.Invalid(self.message("group_exists", state, name=value), value, state)
-            finally:
-                db.recycleConnection(conn, cur)
-        except StandardError, err:
-            print "Fehler beim Validieren des Gruppennamens: %s" % err
-
-class NewUserGroupForm(BaseFormValidator):
-    name = UserGroupExistsCheck(not_empty=True) 
-
-class EditUserGroupForm(NewUserGroupForm):
-    standin = formencode.ForEach(formencode.validators.Int(), convert_to_list=True)
-
 class NewUserForm(BaseFormValidator):
     def __init__(self):
         formencode.api.set_stdtranslation(domain="FormEncode", languages=["de"])



More information about the Mpuls-commits mailing list