<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=US-ASCII">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2657.73">
<TITLE>RE: [Seaside] registerObjectForBacktracking, submit and execute block</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>This subject was already discussed here. See</FONT>
<BR><FONT SIZE=2><A HREF="http://lists.squeakfoundation.org/pipermail/seaside/2004-June/003107.html" TARGET="_blank">http://lists.squeakfoundation.org/pipermail/seaside/2004-June/003107.html</A></FONT>
</P>
<P><FONT SIZE=2>I have actually fixed the problem with a bit of refactoring of the</FONT>
<BR><FONT SIZE=2>snapshot logic by moving the snapshot behavior to Object.</FONT>
<BR><FONT SIZE=2>I defined the following methods in Object</FONT>
<BR><FONT SIZE=2>. snapshotCopy</FONT>
<BR><FONT SIZE=2>. restoreFromSnapshot:</FONT>
<BR><FONT SIZE=2>. isIdenticalToSnapshot:</FONT>
<BR><FONT SIZE=2>And I changed the following methods in WAStateRegistry accordingly</FONT>
<BR><FONT SIZE=2>. registerObject:</FONT>
<BR><FONT SIZE=2>. restoreObject:fromSnapshot:</FONT>
<BR><FONT SIZE=2>. snapshot</FONT>
<BR><FONT SIZE=2>. snapshot:isIdenticalTo:</FONT>
<BR><FONT SIZE=2>The default behaviour remains based on shallowCopy for the snapshot.</FONT>
<BR><FONT SIZE=2>You may however re-implement the three Object methods as needed in subclasses</FONT>
<BR><FONT SIZE=2>to use a deeper copy.</FONT>
</P>
<P><FONT SIZE=2>Michel.</FONT>
</P>
<P><FONT SIZE=2>> -----Original Message-----</FONT>
<BR><FONT SIZE=2>> From: seaside-bounces@lists.squeakfoundation.org</FONT>
<BR><FONT SIZE=2>> [<A HREF="mailto:seaside-bounces@lists.squeakfoundation.org">mailto:seaside-bounces@lists.squeakfoundation.org</A>]On Behalf </FONT>
<BR><FONT SIZE=2>> Of Andreas</FONT>
<BR><FONT SIZE=2>> Nilsson</FONT>
<BR><FONT SIZE=2>> Sent: Sunday, August 29, 2004 2:44 PM</FONT>
<BR><FONT SIZE=2>> To: The Squeak Enterprise Aubergines Server - general discussion.</FONT>
<BR><FONT SIZE=2>> Subject: Re: [Seaside] registerObjectForBacktracking, submit </FONT>
<BR><FONT SIZE=2>> and execute</FONT>
<BR><FONT SIZE=2>> block</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> Ok, that makes sense, didn't know that it used an array internally.</FONT>
<BR><FONT SIZE=2>> Any ideas of how to make backtracking work for adding / </FONT>
<BR><FONT SIZE=2>> removing items </FONT>
<BR><FONT SIZE=2>> from a collection?</FONT>
<BR><FONT SIZE=2>> Somebody must have tried before ;)</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> /Adde</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> On 2004-08-29, at 12.29, radoslav hodnicak wrote:</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> > On Sun, 29 Aug 2004, radoslav hodnicak wrote:</FONT>
<BR><FONT SIZE=2>> ></FONT>
<BR><FONT SIZE=2>> >> Registering object for backtracking doesn't do what you probably</FONT>
<BR><FONT SIZE=2>> >> think it does. It's only sensitive to changes of objects, *not* </FONT>
<BR><FONT SIZE=2>> >> object's</FONT>
<BR><FONT SIZE=2>> >> contents.</FONT>
<BR><FONT SIZE=2>> >></FONT>
<BR><FONT SIZE=2>> >> holder := WAStateHolder new.</FONT>
<BR><FONT SIZE=2>> >></FONT>
<BR><FONT SIZE=2>> >> holder contents: (OrderedCollection with: 1 with: 2).</FONT>
<BR><FONT SIZE=2>> >></FONT>
<BR><FONT SIZE=2>> >> holder contents add: 3. "NO CHANGES HERE, STILL THE SAME OBJECT IN </FONT>
<BR><FONT SIZE=2>> >> HOLDER"</FONT>
<BR><FONT SIZE=2>> >></FONT>
<BR><FONT SIZE=2>> >> holder contents: (holder contents copyWith: 3). "NEW </FONT>
<BR><FONT SIZE=2>> OBJECT IN HOLDER,</FONT>
<BR><FONT SIZE=2>> >> WILL BACKTRACK"</FONT>
<BR><FONT SIZE=2>> ></FONT>
<BR><FONT SIZE=2>> > Ok I didn't explain this good enough - backtracking works </FONT>
<BR><FONT SIZE=2>> for changing</FONT>
<BR><FONT SIZE=2>> > object state too - but it works on shallow copy so the </FONT>
<BR><FONT SIZE=2>> changes it can</FONT>
<BR><FONT SIZE=2>> > detect are only one level deep.</FONT>
<BR><FONT SIZE=2>> ></FONT>
<BR><FONT SIZE=2>> > Take this example with OrderedCollection. The items are internally </FONT>
<BR><FONT SIZE=2>> > held in</FONT>
<BR><FONT SIZE=2>> > an array.</FONT>
<BR><FONT SIZE=2>> ></FONT>
<BR><FONT SIZE=2>> > anOrederedCollection (object1)</FONT>
<BR><FONT SIZE=2>> > --has anArray(items ...) (object2)</FONT>
<BR><FONT SIZE=2>> ></FONT>
<BR><FONT SIZE=2>> > when you register object1 for backtracking, it makes a </FONT>
<BR><FONT SIZE=2>> shallow copy of </FONT>
<BR><FONT SIZE=2>> > it,</FONT>
<BR><FONT SIZE=2>> > which means they share the same instance of object2. And on </FONT>
<BR><FONT SIZE=2>> backtrack, </FONT>
<BR><FONT SIZE=2>> > it</FONT>
<BR><FONT SIZE=2>> > looks whether object1 = object1 copy - and it does, because </FONT>
<BR><FONT SIZE=2>> adding and</FONT>
<BR><FONT SIZE=2>> > removing items changed the same array (object2). If you changed a </FONT>
<BR><FONT SIZE=2>> > simple</FONT>
<BR><FONT SIZE=2>> > instvar holding a string or whatever, then it would work as </FONT>
<BR><FONT SIZE=2>> expected.</FONT>
<BR><FONT SIZE=2>> > Clear enough?</FONT>
<BR><FONT SIZE=2>> ></FONT>
<BR><FONT SIZE=2>> > rado</FONT>
<BR><FONT SIZE=2>> > -- </FONT>
<BR><FONT SIZE=2>> > gentleman, n. - a man who knows how to blog, but doesn't</FONT>
<BR><FONT SIZE=2>> ></FONT>
<BR><FONT SIZE=2>> > _______________________________________________</FONT>
<BR><FONT SIZE=2>> > Seaside mailing list</FONT>
<BR><FONT SIZE=2>> > Seaside@lists.squeakfoundation.org</FONT>
<BR><FONT SIZE=2>> > <A HREF="http://lists.squeakfoundation.org/listinfo/seaside" TARGET="_blank">http://lists.squeakfoundation.org/listinfo/seaside</A></FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> _______________________________________________</FONT>
<BR><FONT SIZE=2>> Seaside mailing list</FONT>
<BR><FONT SIZE=2>> Seaside@lists.squeakfoundation.org</FONT>
<BR><FONT SIZE=2>> <A HREF="http://lists.squeakfoundation.org/listinfo/seaside" TARGET="_blank">http://lists.squeakfoundation.org/listinfo/seaside</A></FONT>
</P>
</BODY>
</HTML>