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

</BODY>
</HTML>