[ZODB-Dev] get_transaction

Chris McDonough chrism@zope.com
Fri, 30 Nov 2001 02:09:55 -0500


You can't commit a transaction in just one of the datastores without
committing it in the other by using get_transaction().commit().  You'd
need to take the individual steps that are taken by the commit code
for each connection (essentially, manually do a commit).

----- Original Message -----
From: "Bill Anderson" <bill@libc.org>
To: <zodb-dev@zope.org>
Sent: Friday, November 30, 2001 1:11 AM
Subject: Re: [ZODB-Dev] get_transaction


> 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. ;) )
>
>
>
>
> _______________________________________________
> For more information about ZODB, see the ZODB Wiki:
> http://www.zope.org/Wikis/ZODB/
>
> ZODB-Dev mailing list  -  ZODB-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zodb-dev
>