summaryrefslogtreecommitdiff
path: root/bin/sql_db.py
diff options
context:
space:
mode:
authorP. Christeas <p_christ@hol.gr>2009-05-06 23:18:13 +0300
committerP. Christeas <p_christ@hol.gr>2009-05-06 23:18:13 +0300
commit3814e4dc7311301cc204e7f93b1c988cab795320 (patch)
tree8309aab1cbca3b4b23ebcd3ce95fff78f5188738 /bin/sql_db.py
parent8fdcadcd9900f948f776c13543185ef4cc26445f (diff)
parent519046bfa4d8fb2451f71493a94584f3fa7f3280 (diff)
Merge commit 'origin/master' into mdv-gpl3-py26
Conflicts: bin/report/interface.py bin/report/printscreen/ps_list.py bin/report/render/__init__.py bin/report/render/rml.py bin/report/render/rml2pdf/trml2pdf.py bin/sql_db.py bzr revid: p_christ@hol.gr-20090506201813-qb71ec85xr08obb1
Diffstat (limited to 'bin/sql_db.py')
-rw-r--r--bin/sql_db.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/bin/sql_db.py b/bin/sql_db.py
index 256df23a1e0..d4679d7d196 100644
--- a/bin/sql_db.py
+++ b/bin/sql_db.py
@@ -73,7 +73,7 @@ class Cursor(object):
@wraps(f)
def wrapper(self, *args, **kwargs):
- if not '_obj' in self.__dict__:
+ if self.__closed:
raise psycopg2.ProgrammingError('Unable to use the cursor after having closed it')
return f(self, *args, **kwargs)
return wrapper
@@ -83,6 +83,7 @@ class Cursor(object):
self._serialized = serialized
self._cnx = pool.getconn()
self._obj = self._cnx.cursor(cursor_factory=psycopg1cursor)
+ self.__closed = False
self.autocommit(False)
self.dbname = pool.dbname
@@ -91,7 +92,7 @@ class Cursor(object):
self.__caller = tuple(stack()[2][1:3])
def __del__(self):
- if '_obj' in self.__dict__ :
+ if not self.__closed:
if tools.config['log_level'] in (netsvc.LOG_DEBUG, netsvc.LOG_DEBUG_RPC):
# Oops. 'self' has not been closed explicitly.
# The cursor will be deleted by the garbage collector,
@@ -117,6 +118,7 @@ class Cursor(object):
now = mdt.now()
try:
+ params = params or None
res = self._obj.execute(query, params)
except psycopg2.ProgrammingError, pe:
logger= netsvc.Logger()
@@ -173,6 +175,7 @@ class Cursor(object):
# collected as fast as they should). The problem is probably due in
# part because browse records keep a reference to the cursor.
del self._obj
+ self.__closed = True
self._pool.putconn(self._cnx)
@check