From feeea0309a2e9f9f5c025ffa7969cd02f6413419 Mon Sep 17 00:00:00 2001 From: Federico Di Gregorio Date: Mon, 12 Sep 2005 02:29:46 +0000 Subject: [PATCH] psycopg->psycopg2 fixes. --- ChangeLog | 2 ++ lib/pool.py | 12 ++++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9472ed98..a1538451 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2005-09-12 Federico Di Gregorio + * lib/pool.py: Applied psycopg->psycopg2 patch to from bug #35. + * ZpsycopgDA/db.py: fixed problem with OperationalError that resulted in cryptic message to Zope users ("'OperationalError' is not defined".) diff --git a/lib/pool.py b/lib/pool.py index c424f20a..5140e203 100644 --- a/lib/pool.py +++ b/lib/pool.py @@ -1,4 +1,4 @@ -"""Connection pooling for psycopg +"""Connection pooling for psycopg2 This module implements thread-safe (and not) connection pools. """ @@ -16,7 +16,7 @@ This module implements thread-safe (and not) connection pools. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. -import psycopg +import psycopg2 try: from zLOG import LOG, DEBUG, INFO @@ -29,12 +29,10 @@ except: def dbg(*args): sys.stderr.write(' '.join(args)+'\n') - -class PoolError(psycopg.Error): +class PoolError(psycopg2.Error): pass - class AbstractConnectionPool(object): """Generic key-based pooling code.""" @@ -62,7 +60,7 @@ class AbstractConnectionPool(object): def _connect(self, key=None): """Create a new connection and assign it to 'key' if not None.""" - conn = psycopg.connect(*self._args, **self._kwargs) + conn = psycopg2.connect(*self._args, **self._kwargs) if key is not None: self._used[key] = conn else: @@ -128,7 +126,6 @@ class AbstractConnectionPool(object): pass self.closed = True - class SimpleConnectionPool(AbstractConnectionPool): """A connection pool that can't be shared across different threads.""" @@ -137,7 +134,6 @@ class SimpleConnectionPool(AbstractConnectionPool): putconn = AbstractConnectionPool._putconn closeall = AbstractConnectionPool._closeall - class ThreadedConnectionPool(AbstractConnectionPool): """A connection pool that works with the threading module.