Hi!
Attached is a small code snippet highlighting some strange behavior.
It outputs:
Writing 'connection_val' to connection foo
Value of transaction foo: 'init'
Writing 'transaction_val' to transaction foo
Value of connection foo: 'connection_val'
Instead of the expected:
Writing 'connection_val' to connection foo
Value of transaction foo: 'connection_val'
Writing 'transaction_val' to transaction foo
Value of connection foo: 'connection_val'
Is this behavior intentional? (ie can I rely on it)
Is is sqlite3 related? (right now I can't test it on another DB)
How should I fix this?
.expire()? .sync()?
Invalidate the transaction's cache?
Caching behavior in sqlobject looks like some can worms to me.
regards
Herwig Hochleitner
import sqlobject
# Turn off caching so that multiple connections (ie transactions) sync properly
conn = sqlobject.connectionForURI("sqlite:/:memory:", debug=True, logger="database.query", loglevel="debug", cache=False)
class Dummy(sqlobject.SQLObject):
foo = sqlobject.StringCol()
Dummy.createTable(connection=conn)
Dummy(foo="init", connection=conn)
tr = conn.transaction()
conn_dummy=Dummy.get(1,conn)
trans_dummy=Dummy.get(1,tr)
print "Writing 'connection_val' to connection foo"
conn_dummy.foo = "connection_val"
print "Value of transaction foo: '%s'" % trans_dummy.foo
print "Writing 'transaction_val' to transaction foo"
trans_dummy.foo = "transaction_val"
print "Value of connection foo: '%s'" % conn_dummy.foo
------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss