[Seaside] registerObjectForBacktracking, submit and execute block

Andreas Nilsson wahboh at mac.com
Sun Aug 29 14:43:58 CEST 2004


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



More information about the Seaside mailing list