[SQLObject] autoCommit, PostgresConnection problems
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Guenther S. <gs...@sy...> - 2003-12-21 13:10:55
|
=2D----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi all, I digged a little bit around in the SQLObject source & found some things wh= ich=20 look like bugs to me (altough i'm not really sure :). Maybe someone who=20 understands the framework better than me can review these / resolve them. =2D --- DBConnection.py / PostgresConnection / __init__: =2D -------- 8< -------- 8< -------- 8< -------- 8< -------- 8< -------- def __init__(self, dsn=3DNone, host=3DNone, db=3DNone, ___ user=3DNone, passwd=3DNone, autoCommit=3D1, ___ usePygresql=3DFalse, ___ **kw): [...] self.autoCommit =3D autoCommit [...] DBAPI.__init__(self, **kw) =2D -------- 8< -------- 8< -------- 8< -------- 8< -------- 8< -------- When you run PostgresConnection with the argument 'autoCommit =3D 0' in the= =20 constructor it sets self.autoCommit to 0 too. But afterwards it calls DBAPI.__init__ only with **kw, but not with the oth= er=20 named arguments. DBAPI.__init__ calls DBConnection.__init__ which doesn't g= et=20 the autoCommit argument (because it isn't stored in **kw) and which default= s=20 to 'autoCommit=3DTrue'. Therefore autoCommit is always True, no matter which value is passed to the= =20 PostgresConnection Constructor. =2D --- DBConnection.py / class DBAPI / releaseConnection: =2D -------- 8< -------- 8< -------- 8< -------- 8< -------- 8< -------- elif self.autoCommit: ___ if self.debug: _______ self.printDebug(conn, 'auto', 'COMMIT') ___ conn.commit() =2D -------- 8< -------- 8< -------- 8< -------- 8< -------- 8< -------- when autoCommit is active the PgSQL adapter throws an 'Commit failed -=20 autocommit is on.' exception when commit() is called. Shouldn't this be a 'elif not self.autoCommit' instead (without an else=20 statement afterwards)? Imo the connection only needs the 'COMMIT' if it isn= 't=20 set to autoCommit. There is another similiar Problem with the 'pool' argument which is added b= y=20 PostgresConnection to **kw, but which isn't expected by DBConnection. (I=20 posted bug #859999 some time ago on the SourceForge project page). =2D --- btw, I have used my PgSQL adapter (i posted a patch some time ago) now for= =20 some time without any major problems. As (AFAIK) the only Python PostgreSQL Library PgSQL supports Unicode (my=20 adapter should support this, though i have to admit that i haven't really=20 tested it yet). As PgSQL Code is in its own class (inherited from=20 PostgresConnection), it shouldn't affect any other code. If there's a chance of getting PgSQL Support into SQLObject i'll repost my= =20 patch to it. cu /gst =2D----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQE/5ZumZtF7I/+gjcERAl/rAJ42A0m6XKIHqxi4WHaXuxwVPIIT2wCghx6Q 9Iglk+dsGtB5Usn1giTfUsw=3D =3Dmp5M =2D----END PGP SIGNATURE----- |