[Mpuls-commits] r1026 - in wasko/branches/2.0: . waskaweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Jan 29 17:55:35 CET 2010


Author: bh
Date: 2010-01-29 17:55:31 +0100 (Fri, 29 Jan 2010)
New Revision: 1026

Modified:
   wasko/branches/2.0/ChangeLog
   wasko/branches/2.0/waskaweb/lib/security.py
Log:
* waskaweb/lib/security.py (checkLogin): Use ensure_unicode to
convert to unicode instead of hardcoding the conversion inline.


Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog	2010-01-29 15:21:29 UTC (rev 1025)
+++ wasko/branches/2.0/ChangeLog	2010-01-29 16:55:31 UTC (rev 1026)
@@ -1,5 +1,10 @@
 2010-01-29  Bernhard Herzog  <bh at intevation.de>
 
+	* waskaweb/lib/security.py (checkLogin): Use ensure_unicode to
+	convert to unicode instead of hardcoding the conversion inline.
+
+2010-01-29  Bernhard Herzog  <bh at intevation.de>
+
 	* waskaweb/lib/security.py (ROLE_SQL): Removed.  Unused.
 
 2010-01-29  Bernhard Herzog  <bh at intevation.de>

Modified: wasko/branches/2.0/waskaweb/lib/security.py
===================================================================
--- wasko/branches/2.0/waskaweb/lib/security.py	2010-01-29 15:21:29 UTC (rev 1025)
+++ wasko/branches/2.0/waskaweb/lib/security.py	2010-01-29 16:55:31 UTC (rev 1026)
@@ -100,6 +100,12 @@
         or not check_re.match(user)):
         return None
 
+    # imported here, because waskaweb.lib.helpers also imports
+    # waskaweb.lib.security which leads to circular imports.
+    # ensure_unicode shouldn't be needed here anymore anyway when the
+    # database returns Unicode objects directly.
+    from waskaweb.lib.helpers import ensure_unicode
+
     log.info('Login: user "%s" in "%s"' % (user, dbname))
     try:
         mydb = DB(dbname=DBNAME % dbname, host=HOST, port=PORT,
@@ -117,15 +123,16 @@
                     result = cursor.fetchone()
                     data = {}
                     data['id'] = result[0]
-                    data['firstname'] = unicode(str(result[1]), 'utf-8')
-                    data['lastname'] = unicode(str(result[2]), 'utf-8')
+                    data['firstname'] = ensure_unicode(result[1])
+                    data['lastname'] = ensure_unicode(result[2])
                     data['newpass'] = result[3]
                     data['activated'] = result[4]
-                    data['role'] = unicode(str(result[5]), 'utf-8')
+                    data['role'] = ensure_unicode(result[5])
                     data['gid'] = result[6]
                     data['last_login'] = result[7]
                     data['standin'] = result[8]
                 except:
+                    log.exception("Error fetching user data")
                     data = None
             finally:
                 db.recycleConnection(conn, cursor)



More information about the Mpuls-commits mailing list