Author: ianb
Date: 2004-08-17 23:06:00 -0400 (Tue, 17 Aug 2004)
New Revision: 191
Modified:
trunk/SQLObject/sqlobject/dbconnection.py
trunk/SQLObject/tests/test.py
Log:
Fixed some transaction bugs
Modified: trunk/SQLObject/sqlobject/dbconnection.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/sqlobject/dbconnection.py 2004-08-18 02:53:07 UTC (re=
v 190)
+++ trunk/SQLObject/sqlobject/dbconnection.py 2004-08-18 03:06:00 UTC (re=
v 191)
@@ -148,7 +148,7 @@
else:
s +=3D ' pool=3D[%s]' % ', '.join([str(self._connectionN=
umbers[id(v)]) for v in self._pool])
self.printDebug(conn, s, 'Pool')
- if self.supportTransactions:
+ if self.supportTransactions and not explicit:
if self.autoCommit =3D=3D 'exception':
if self.debug:
self.printDebug(conn, 'auto/exception', 'ROLLBACK')
@@ -435,6 +435,9 @@
dbconn.printDebug(rawconn, self.query, 'Select')
self.dbconn._executeRetry(self.rawconn, self.cursor, self.query)
=20
+ def __iter__(self):
+ return self
+
def next(self):
result =3D self.cursor.fetchone()
if result is None:
@@ -497,8 +500,8 @@
# still iterating through the results.
# @@: But would it be okay for psycopg, with threadsafety
# level 2?
- return list(Iteration(self, self._connection,
- select, keepConnection=3DTrue))
+ return iter(list(Iteration(self, self._connection,
+ select, keepConnection=3DTrue)))
=20
def commit(self):
if self._obsolete:
Modified: trunk/SQLObject/tests/test.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/tests/test.py 2004-08-18 02:53:07 UTC (rev 190)
+++ trunk/SQLObject/tests/test.py 2004-08-18 03:06:00 UTC (rev 191)
@@ -442,6 +442,7 @@
TestSOTrans._connection.autoCommit =3D 'exception'
TestSOTrans(name=3D'joe', connection=3Dtrans)
trans.rollback()
+ trans.begin()
self.assertEqual([n.name for n in TestSOTrans.select(connect=
ion=3Dtrans)],
['bob', 'tim'])
b =3D TestSOTrans.byName('bob', connection=3Dtrans)
@@ -450,6 +451,7 @@
self.assertEqual(b.name, 'robert')
b.name =3D 'bob'
trans.rollback()
+ trans.begin()
self.assertEqual(b.name, 'robert')
finally:
TestSOTrans._connection.autoCommit =3D True
@@ -886,6 +888,7 @@
class SOStringID(SQLObject):
=20
_table =3D 'so_string_id'
+ _idType =3D str
val =3D StringCol(alternateID=3DTrue)
=20
mysqlCreate =3D """
|