[Mpuls-commits] r3122 - in base/trunk: . mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Jul 2 20:06:09 CEST 2010


Author: bh
Date: 2010-07-02 20:06:06 +0200 (Fri, 02 Jul 2010)
New Revision: 3122

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/lib/security.py
Log:
* mpulsweb/lib/security.py (checkLogin): Use DB.execute to execute
the UPDATE_LASTLOGIN_SQL statement


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2010-07-02 17:58:07 UTC (rev 3121)
+++ base/trunk/ChangeLog	2010-07-02 18:06:06 UTC (rev 3122)
@@ -1,5 +1,10 @@
 2010-07-02  Bernhard Herzog  <bh at intevation.de>
 
+	* mpulsweb/lib/security.py (checkLogin): Use DB.execute to execute
+	the UPDATE_LASTLOGIN_SQL statement
+
+2010-07-02  Bernhard Herzog  <bh at intevation.de>
+
 	* mpulsweb/lib/db.py (DB.execute): New.  Handle the common case
 	where one SQL statement has to be executed as a transaction.  This
 	should be used in all places where appropriate to make sure that

Modified: base/trunk/mpulsweb/lib/security.py
===================================================================
--- base/trunk/mpulsweb/lib/security.py	2010-07-02 17:58:07 UTC (rev 3121)
+++ base/trunk/mpulsweb/lib/security.py	2010-07-02 18:06:06 UTC (rev 3122)
@@ -149,20 +149,13 @@
                     return None
 
                 # UPDATE last login time
-                conn, cursor = None, None
-                try:
-                    conn = db.getConnection()
-                    cursor = conn.cursor()
-                    if data:
-                        try:
-                            fields = {'user_id': data.get('id')}
-                            cursor.execute(UPDATE_LASTLOGIN_SQL, fields)
-                            conn.commit()
-                        except StandardError:
-                            log.exception("Error setting last logintime: %r",
-                                          cursor.query)
-                finally:
-                    db.recycleConnection(conn, cursor)
+                if data:
+                    try:
+                        db.execute(UPDATE_LASTLOGIN_SQL,
+                                   {'user_id': data.get('id')})
+                    except StandardError:
+                        log.exception("Error setting last login time for"
+                                      " user %r" % (data.get('id'),))
 
             except StandardError:
                 log.exception("Error creating user Object")



More information about the Mpuls-commits mailing list