diff --git a/NEWS b/NEWS index 4bb218e9..fb2e4cc8 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ What's new in psycopg 2.4.4 --------------------------- - Named DictCursor/RealDictCursor honour itersize (ticket #80). + - Fixed rollback on error on Zope (ticket #73). What's new in psycopg 2.4.3 diff --git a/ZPsycopgDA/db.py b/ZPsycopgDA/db.py index fe27931c..2d85b21d 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):