[ZODB-Dev] Sequences and ZODB conflicts

Toby Dickenson tdickenson@geminidataloggers.com
Wed, 29 Jan 2003 11:16:50 +0000


On Wednesday 29 January 2003 10:57 am, Christian Reis wrote:
> On Wed, Jan 29, 2003 at 10:15:29AM +0000, Toby Dickenson wrote:
> > On Wednesday 29 January 2003 1:27 am, Christian Reis wrote:
> > > Have I lost the chance to save this instance forever
> >
> > Yes. You should repeat the transaction from the beginning.
>
> Could I also use _p_resolveConflict to try and fix this situation?

If that is possible in application terms, yes. Unless this is as simple a=
s a=20
page hit counter then I guess this will be hard. The tip from Chris M may=
=20
work if this is all you need.

> One thing I wonder about it, though, is in which object it will be
> actually be called.

None. Inside _p_resolveConflict the 'self' object has undefined state. It=
s=20
just there to hang the _p_resolveConflict method on.

> So it would only be
> called for the Sequence object - and from there I would need to update
> the domain object to use the new value.

Thats not possible. inside _p_resolveConflict you have access to the two=20
conflicting objects, but none others. Any persistent reference attributes=
 are=20
replaced with stubs that can only be compared for equality.

> > Of course this raises a risk that a failure between the two transacti=
ons
> > might cause a number to be lost. I think there might be a way around =
this
> > using versions....
>
> It's what I thought, too. But it seems nobody knows how to use ZODB
> versions! <wink>

--=20
Toby Dickenson
http://www.geminidataloggers.com/people/tdickenson