[ZODB-Dev] get_transaction

Bill Anderson bill@libc.org
29 Nov 2001 23:11:28 -0700


On Thu, 2001-11-29 at 14:51, Michel Pelletier wrote:
> Magnus Heino wrote:
> > 
> > Hi.
> > 
> > I have  a question about get_transaction()
> > 
> > ---
> > 
> > from ZODB import FileStorage, DB
> > 
> > storage = FileStorage.FileStorage('/tmp/test-filestorage.fs')
> > db = DB( storage )
> > conn = db.open()
> > 
> > root1 = conn.root()
> > root2 = conn.root()
> > 
> > root1[1] = 1
> > root2[2] = 2
> > 
> > get_transaction().commit()
> > 
> > ---
> > 
> > What will be committed? Both connections? Can I control that?
> 
> There's only one connection, you created two references to the same
> object.

OK, how about this:

from ZODB import FileStorage, DB

storage1 = FileStorage.FileStorage('/tmp/test-filestorage1.fs')
db1 = DB( storage1 )
conn1 = db1.open()

storage2 = FileStorage.FileStorage('/tmp/test-filestorage2.fs')
db2 = DB( storage2 )
conn2 = db2.open()

root1 = conn1.root()
root2 = conn2.root()

root1[1]=1
root2[2]=2
get_transaction().commit()

:^)=

("Don't do that is not exactly an acceptable answer, either. ;) )