psycopg->psycopg2 fixes.

This commit is contained in:
Federico Di Gregorio 2005-09-12 02:29:46 +00:00
parent f4b52e8cdd
commit feeea0309a
2 changed files with 6 additions and 8 deletions

View File

@ -1,5 +1,7 @@
2005-09-12 Federico Di Gregorio <fog@initd.org>
* 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".)

View File

@ -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.