diff options
| author | Federico Di Gregorio <fog@initd.org> | 2011-12-16 10:37:01 +0100 |
|---|---|---|
| committer | Federico Di Gregorio <fog@initd.org> | 2011-12-16 10:37:01 +0100 |
| commit | 71a4c2bac92fe4d30923490f37b993d938266e5d (patch) | |
| tree | a735fd643f4b539ac48526abf32363f44c70112e /ZPsycopgDA | |
| parent | b5de04d2ff6fd50b7e4fd06516ac396d9c79d8b6 (diff) | |
| download | psycopg2-71a4c2bac92fe4d30923490f37b993d938266e5d.tar.gz | |
Fixed rollback on error on Zope (ticket #73)
Diffstat (limited to 'ZPsycopgDA')
| -rw-r--r-- | ZPsycopgDA/db.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/ZPsycopgDA/db.py b/ZPsycopgDA/db.py index fe27931..2d85b21 100644 --- a/ZPsycopgDA/db.py +++ b/ZPsycopgDA/db.py @@ -47,12 +47,15 @@ class DB(TM, dbi_db.DB): self.calls = 0 self.make_mappings() - def getconn(self, create=True): + def getconn(self, init=True): + # if init is False we are trying to get hold on an already existing + # connection, so we avoid to (re)initialize it risking errors. conn = pool.getconn(self.dsn) - conn.set_isolation_level(int(self.tilevel)) - conn.set_client_encoding(self.encoding) - for tc in self.typecasts: - register_type(tc, conn) + if init: + conn.set_isolation_level(int(self.tilevel)) + conn.set_client_encoding(self.encoding) + for tc in self.typecasts: + register_type(tc, conn) return conn def putconn(self, close=False): |
