Package: python-sqlobject
Version: 0.12.4-2

--- Please enter the report below this line. ---

I experienced the same problem.

Attached you find a patch that fixes the issue for me.
It simply checks, if the "autocommit" attribute is callable - otherwise 
the attribute is ignored (as it should be).

cheers,
Lars

--- System information. ---
Architecture: i386
Kernel:       Linux 3.0.0-1-686-pae

Debian Release: wheezy/sid
  500 testing         apt-proxy 
  500 lucid           ppa.launchpad.net 

--- Package information. ---
Depends                    (Version) | Installed
====================================-+-============
python                               | 2.6.7-2
python-support           (>= 0.90.0) | 1.0.14
python-pkg-resources      (>= 0.6c8) | 0.6.16-1
python-formencode                    | 1.2.4-2


Package's Recommends field is empty.

Suggests                (Version) | Installed
=================================-+-===========
python-mysqldb                    | 
python-sqlite                     | 
python-psycopg2                   | 2.4.2-1
python-kinterbasdb                | 
python-maxdb                      | 

diff -ruN sqlobject.orig//postgres/pgconnection.py sqlobject/postgres/pgconnection.py
--- sqlobject.orig//postgres/pgconnection.py	2010-01-06 16:43:11.000000000 +0100
+++ sqlobject/postgres/pgconnection.py	2011-08-15 15:44:13.000000000 +0200
@@ -115,8 +115,8 @@
     connectionFromURI = classmethod(connectionFromURI)
 
     def _setAutoCommit(self, conn, auto):
-        # psycopg2 does not have an autocommit method.
-        if hasattr(conn, 'autocommit'):
+        # psycopg2 does not have an autocommit method, but a bool attribute with that name
+        if hasattr(conn, 'autocommit') and callable(conn.autocommit):
             conn.autocommit(auto)
 
     def makeConnection(self):
@@ -128,8 +128,8 @@
         except self.module.OperationalError, e:
             raise self.module.OperationalError("%s; used connection string %r" % (e, self.dsn))
         if self.autoCommit:
-            # psycopg2 does not have an autocommit method.
-            if hasattr(conn, 'autocommit'):
+            # psycopg2 does not have an autocommit method, but a bool attribute with that name
+            if hasattr(conn, 'autocommit') and callable(conn.autocommit):
                 conn.autocommit(1)
         c = conn.cursor()
         if self.schema:

Reply via email to