[Seaside] registerObjectForBacktracking, submit and execute b lock

Bany, Michel mbany at cincom.com
Mon Aug 30 11:09:19 CEST 2004


This subject was already discussed here. See
http://lists.squeakfoundation.org/pipermail/seaside/2004-June/003107.html

I have actually fixed the problem with a bit of refactoring of the
snapshot logic by moving the snapshot behavior to Object.
I defined the following methods in Object
. snapshotCopy
. restoreFromSnapshot:
. isIdenticalToSnapshot:
And I changed the following methods in WAStateRegistry accordingly
. registerObject:
. restoreObject:fromSnapshot:
. snapshot
. snapshot:isIdenticalTo:
The default behaviour remains based on shallowCopy for the snapshot.
You may however re-implement the three Object methods as needed in
subclasses
to use a deeper copy.

Michel.

> -----Original Message-----
> From: seaside-bounces at lists.squeakfoundation.org
> [mailto:seaside-bounces at lists.squeakfoundation.org]On Behalf 
> Of Andreas
> Nilsson
> Sent: Sunday, August 29, 2004 2:44 PM
> To: The Squeak Enterprise Aubergines Server - general discussion.
> Subject: Re: [Seaside] registerObjectForBacktracking, submit 
> and execute
> block
> 
> 
> Ok, that makes sense, didn't know that it used an array internally.
> Any ideas of how to make backtracking work for adding / 
> removing items 
> from a collection?
> Somebody must have tried before ;)
> 
> /Adde
> 
> On 2004-08-29, at 12.29, radoslav hodnicak wrote:
> 
> > On Sun, 29 Aug 2004, radoslav hodnicak wrote:
> >
> >> Registering object for backtracking doesn't do what you probably
> >> think it does. It's only sensitive to changes of objects, *not* 
> >> object's
> >> contents.
> >>
> >> holder := WAStateHolder new.
> >>
> >> holder contents: (OrderedCollection with: 1 with: 2).
> >>
> >> holder contents add: 3. "NO CHANGES HERE, STILL THE SAME OBJECT IN 
> >> HOLDER"
> >>
> >> holder contents: (holder contents copyWith: 3). "NEW 
> OBJECT IN HOLDER,
> >> WILL BACKTRACK"
> >
> > Ok I didn't explain this good enough - backtracking works 
> for changing
> > object state too - but it works on shallow copy so the 
> changes it can
> > detect are only one level deep.
> >
> > Take this example with OrderedCollection. The items are internally 
> > held in
> > an array.
> >
> > anOrederedCollection (object1)
> > --has anArray(items ...) (object2)
> >
> > when you register object1 for backtracking, it makes a 
> shallow copy of 
> > it,
> > which means they share the same instance of object2. And on 
> backtrack, 
> > it
> > looks whether object1 = object1 copy - and it does, because 
> adding and
> > removing items changed the same array (object2). If you changed a 
> > simple
> > instvar holding a string or whatever, then it would work as 
> expected.
> > Clear enough?
> >
> > rado
> > -- 
> > gentleman, n. - a man who knows how to blog, but doesn't
> >
> > _______________________________________________
> > Seaside mailing list
> > Seaside at lists.squeakfoundation.org
> > http://lists.squeakfoundation.org/listinfo/seaside
> 
> _______________________________________________
> Seaside mailing list
> Seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/listinfo/seaside
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20040830/237b11e2/attachment.htm


More information about the Seaside mailing list