mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-26 19:03:43 +03:00
psycopg->psycopg2 fixes.
This commit is contained in:
parent
f4b52e8cdd
commit
feeea0309a
|
@ -1,5 +1,7 @@
|
||||||
2005-09-12 Federico Di Gregorio <fog@initd.org>
|
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
|
* ZpsycopgDA/db.py: fixed problem with OperationalError that resulted in
|
||||||
cryptic message to Zope users ("'OperationalError' is not defined".)
|
cryptic message to Zope users ("'OperationalError' is not defined".)
|
||||||
|
|
||||||
|
|
12
lib/pool.py
12
lib/pool.py
|
@ -1,4 +1,4 @@
|
||||||
"""Connection pooling for psycopg
|
"""Connection pooling for psycopg2
|
||||||
|
|
||||||
This module implements thread-safe (and not) connection pools.
|
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
|
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
# for more details.
|
# for more details.
|
||||||
|
|
||||||
import psycopg
|
import psycopg2
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from zLOG import LOG, DEBUG, INFO
|
from zLOG import LOG, DEBUG, INFO
|
||||||
|
@ -29,12 +29,10 @@ except:
|
||||||
def dbg(*args):
|
def dbg(*args):
|
||||||
sys.stderr.write(' '.join(args)+'\n')
|
sys.stderr.write(' '.join(args)+'\n')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PoolError(psycopg.Error):
|
class PoolError(psycopg2.Error):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class AbstractConnectionPool(object):
|
class AbstractConnectionPool(object):
|
||||||
"""Generic key-based pooling code."""
|
"""Generic key-based pooling code."""
|
||||||
|
@ -62,7 +60,7 @@ class AbstractConnectionPool(object):
|
||||||
|
|
||||||
def _connect(self, key=None):
|
def _connect(self, key=None):
|
||||||
"""Create a new connection and assign it to 'key' if not 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:
|
if key is not None:
|
||||||
self._used[key] = conn
|
self._used[key] = conn
|
||||||
else:
|
else:
|
||||||
|
@ -128,7 +126,6 @@ class AbstractConnectionPool(object):
|
||||||
pass
|
pass
|
||||||
self.closed = True
|
self.closed = True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SimpleConnectionPool(AbstractConnectionPool):
|
class SimpleConnectionPool(AbstractConnectionPool):
|
||||||
"""A connection pool that can't be shared across different threads."""
|
"""A connection pool that can't be shared across different threads."""
|
||||||
|
@ -137,7 +134,6 @@ class SimpleConnectionPool(AbstractConnectionPool):
|
||||||
putconn = AbstractConnectionPool._putconn
|
putconn = AbstractConnectionPool._putconn
|
||||||
closeall = AbstractConnectionPool._closeall
|
closeall = AbstractConnectionPool._closeall
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ThreadedConnectionPool(AbstractConnectionPool):
|
class ThreadedConnectionPool(AbstractConnectionPool):
|
||||||
"""A connection pool that works with the threading module.
|
"""A connection pool that works with the threading module.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user