That's funny. I've seen that in my own test cases and never paid it
too much attention. This is definitely the same problem... The
database is closed, but the Transaction's __del__ method is trying to
perform a rollback on the database.
On 6/23/05, Daishi Harada <daishi@...> wrote:
> I'm not sure this is entirely related, but I'm seeing:
> Exception pysqlite2.dbapi2.ProgrammingError: 'Cannot operate on a
> closed database.' in <bound method Transaction.__del__ of
> <sqlobject.dbconnection.Transaction object at 0xb6f9ca2c>> ignored
> on the attached test code, which goes away if I
> add a _makeObsolete call in Transaction.commit().
> (I'm using the current pysqlite2 and sqlobject).
> I'm wondering if I'm just not doing the right thing
> in the test code, or if I should ignore the message,
> or if there's something actually wrong elsewhere.
> In particular, is there a better way to obtain the
> transaction then accessing ._connection as I do?
> On a separate note, I see that DBConnection has
> a queryOne() method; is there a corresponding
> "get_one" method at the SQLObject level that
> can replace the iter(select()).next() hack in query()
> import sqlobject
> URI =3D 'sqlite:/:memory:'
> N =3D 10
> class Test(sqlobject.SQLObject):
> class sqlmeta:
> cacheValues =3D False
> _connection =3D sqlobject.connectionForURI(URI)
> foo =3D sqlobject.StringCol()
> def create():
> def load():
> transaction =3D Test._connection.transaction()
> for i in xrange(N):
> Test(foo=3Dstr(i), connection=3Dtransaction)
> def query():
> for i in xrange(N):
> x =3D iter(Test.selectBy(foo=3Dstr(i))).next()
> #print x
> def main():
> #Test._connection.debug =3D True
> if __name__ =3D=3D '__main__':
> On Jun 21, 2005, at 6:23 AM, Kevin Dangoor wrote:
> > In dbconnection.py, the error messages seem to imply that after you've
> > committed (or rolled back) a transaction, you need to either get a new
> > transaction object or call begin(). Looking at the code, though,
> > rollback calls _makeObsolete, whereas commit does not.
> > This is causing some interesting behavior in my test code, because I
> > made some database updates that I hadn't committed and they were
> > getting rolled back when the previous, already committed transaction
> > was garbage collected.
> > I can certainly add an explicit rollback in my own code, but I wanted
> > to see if there really should be a makeObsolete call in there.
> > Kevin
> > -------------------------------------------------------
> > SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
> > from IBM. Find simple to follow Roadmaps, straightforward articles,
> > informative Webcasts and more! Get everything you need to get up to
> > speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id=16492&op=3Dclick
> > _______________________________________________
> > sqlobject-discuss mailing list
> > sqlobject-discuss@...
> > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss