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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Jan 29 11:05:59 CET 2010


Author: bh
Date: 2010-01-29 11:05:58 +0100 (Fri, 29 Jan 2010)
New Revision: 1005

Modified:
   wasko/branches/2.0/ChangeLog
   wasko/branches/2.0/waskaweb/lib/db.py
Log:
* waskaweb/lib/db.py (DB.recycleConnection, DB.closeConnections):
Use the logging module to log warnings.  Also, do not ignore
exceptions, log them.


Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog	2010-01-29 09:53:51 UTC (rev 1004)
+++ wasko/branches/2.0/ChangeLog	2010-01-29 10:05:58 UTC (rev 1005)
@@ -1,5 +1,11 @@
 2010-01-29  Bernhard Herzog  <bh at intevation.de>
 
+	* waskaweb/lib/db.py (DB.recycleConnection, DB.closeConnections):
+	Use the logging module to log warnings.  Also, do not ignore
+	exceptions, log them.
+
+2010-01-29  Bernhard Herzog  <bh at intevation.de>
+
 	* waskaweb/lib/db.py: Fix formatting
 
 2010-01-28  Bernhard Herzog  <bh at intevation.de>

Modified: wasko/branches/2.0/waskaweb/lib/db.py
===================================================================
--- wasko/branches/2.0/waskaweb/lib/db.py	2010-01-29 09:53:51 UTC (rev 1004)
+++ wasko/branches/2.0/waskaweb/lib/db.py	2010-01-29 10:05:58 UTC (rev 1005)
@@ -27,13 +27,18 @@
 # Authors:
 # Sascha L. Teichmann <teichmann at intevation.de>
 #
+
 import sys
+import logging
 
 import psycopg2 as dbapi
 
 from paste.registry import StackedObjectProxy
 
 
+log = logging.getLogger(__name__)
+
+
 db = StackedObjectProxy(name="waska.db")
 
 
@@ -74,24 +79,24 @@
             try:
                 cur.close()
             except:
-                pass
+                log.exception("Error ignored while closing cursor")
         if con:
             for used in self.connections:
                 if used[1] == con:
                     used[0] = False
                     return
-            print >> sys.stderr, "WARNING: tried to recycle unused connection"
+            log.warning("WARNING: tried to recycle unused connection")
 
     def closeConnections(self):
         cons = self.connections
         self.connections = []
         for used in cons:
             if used[0]:
-                print >> sys.stderr, "WARNING: Closing an unrecylcled connection"
+                log.warning("WARNING: Closing an unrecycled connection")
             try:
                 used[0].close()
             except:
-                pass
+                log.exception("Error ignored while closing connection")
 
 
 class DBInterface:



More information about the Mpuls-commits mailing list