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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Jan 29 18:14:53 CET 2010


Author: bh
Date: 2010-01-29 18:14:51 +0100 (Fri, 29 Jan 2010)
New Revision: 1027

Modified:
   wasko/branches/2.0/ChangeLog
   wasko/branches/2.0/waskaweb/lib/security.py
Log:
* waskaweb/lib/security.py (checkLogin)
(load_db_mapping_from_file, getDbName): Improve logging.


Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog	2010-01-29 16:55:31 UTC (rev 1026)
+++ wasko/branches/2.0/ChangeLog	2010-01-29 17:14:51 UTC (rev 1027)
@@ -1,5 +1,10 @@
 2010-01-29  Bernhard Herzog  <bh at intevation.de>
 
+	* waskaweb/lib/security.py (checkLogin)
+	(load_db_mapping_from_file, getDbName): Improve logging.
+
+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.
 

Modified: wasko/branches/2.0/waskaweb/lib/security.py
===================================================================
--- wasko/branches/2.0/waskaweb/lib/security.py	2010-01-29 16:55:31 UTC (rev 1026)
+++ wasko/branches/2.0/waskaweb/lib/security.py	2010-01-29 17:14:51 UTC (rev 1027)
@@ -157,15 +157,14 @@
                             fields = {'user_id': data.get('id')}
                             cursor.execute(UPDATE_LASTLOGIN_SQL, fields)
                             conn.commit()
-                        except StandardError, err:
-                            traceback.print_exc(file=sys.stderr)
-                            print "Error on setting last logintime: %s" % cursor.query
+                        except StandardError:
+                            log.exception("Error setting last logintime: %r",
+                                          cursor.query)
                 finally:
                     db.recycleConnection(conn, cursor)
 
-            except StandardError, err:
-                traceback.print_exc(file=sys.stderr)
-                print "Error on creating user Object: %s" % err
+            except StandardError:
+                log.exception("Error creating user Object")
 
             #RETURN userobject
             log.info('Login ok :)')
@@ -177,9 +176,10 @@
         # This is likely a login failure
         # XXX: Is there a way in DB Api 2.0 to determine
         # this database independent?
-        traceback.print_exc(file=sys.stderr)
+        log.exception("OperationalError from database"
+                      " while checking user credentials")
     except:
-        traceback.print_exc(file=sys.stderr)
+        log.exception("Exception while checking user credentials")
     log.info('Login failed :(')
     return None
 
@@ -219,10 +219,11 @@
         finally:
             if f:
                 try: f.close()
-                except StandardError, e:
-                    print e
+                except StandardError:
+                    log.exception("Exception while closing db mapping file %r",
+                                  fname)
     else:
-        print >> sys.stderr, "No file mapping file found named: %s" % fname
+        log.warning("No file mapping file found named: %r", fname)
 
 def getDbName():
     dbname = None
@@ -234,7 +235,8 @@
             dbname = config.get('mpuls.db.name')
             return NEW_DBS.get(dbname, dbname)
         except:
-            log.error("Could not fetch database name from client certificate")
+            log.exception("Could not fetch database name from client"
+                          " certificate")
     return dbname
 
 def getKAName():



More information about the Mpuls-commits mailing list