[Borges-users] Transactions (Was: Borges Documentation)
Eric Hodel
drbrain at segment7.net
Fri Mar 19 19:11:53 EST 2004
Kaspar Schiess (eule at space.ch) wrote:
> | Yes... I'm not 100% sure those [transactions] work correctly.
>
> Well they did not. And now they do, kind of. The code will have to
> mature; see attached patch for your today's CVS.
I need to check these patches against Seaside, to see if the problem is
in StateRegistry, or elsewhere. Inline are my dim recollections of how
this is supposed to work.
> diff -r -b -c borges/TestCase/StateRegistryTest.rb borges-transactions/TestCase/StateRegistryTest.rb
> *** borges/TestCase/StateRegistryTest.rb Thu Mar 18 08:25:47 2004
> --- borges-transactions/TestCase/StateRegistryTest.rb Fri Mar 19 15:56:19 2004
> +
> + def test_restore_array_as_content
> + a.contents << 't'
> +
> + @registry.restore_snapshot snap1
> + assert_equal 0, a.contents.size
> +
> + @registry.restore_snapshot snap2
> + assert_equal 1, a.contents.size
> + end
> +
> + def test_restore_array_direct
> + a << 't'
> +
> + @registry.restore_snapshot snap1
> + assert_equal 0, a.size
> +
> + @registry.restore_snapshot snap2
> + assert_equal 1, a.size
> + end
In both tests, the contents should be tested as well, just to make sure
that its the same 't' (a shallow copy).
> diff -r -b -c borges/Utilities/StateRegistry.rb borges-transactions/Utilities/StateRegistry.rb
> *** borges/Utilities/StateRegistry.rb Sat Dec 20 20:55:06 2003
> --- borges-transactions/Utilities/StateRegistry.rb Fri Mar 19 15:56:19 2004
> + class Object
> + def snapshot_shallow_recurse?
> + false
> + end
I'll have to double-check against Seaside, I think that only shallow
copies are supposed to be made. I have a hunch you're right about Array
though. I'll have to investigate more.
> + def snapshot_dup
> + copy = self.dup
Re-reading #dup vs #clone, we should use #clone.
I think #make_snapshot or #snapshot (is that used?) would be better
names.
--
Eric Hodel - drbrain at segment7.net - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/borges-users/attachments/20040319/8877e927/attachment.bin
More information about the Borges-users
mailing list