[Borges-users] Re: Borges Documentation
Kaspar Schiess
eule at space.ch
Fri Mar 19 16:48:48 EST 2004
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hey Eric,
| I'll still have to write an RDtoZenWebRenderer for ZenWeb, that will
| pass along the links into RDoc for web rendering... or something.
Need a hand with this ? You sound overwhelmed ;).
| Yes... I'm not 100% sure those 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 think this is the same idea as "session forking" where you can do two
| operations with the same session. Each fork of the session will
| backtrack over its history independently, but session state will remain
| global to all forks.
And to put that in english, I open up another window in my browser and
continue a different ui thread there, having two interactions with the
system at once. Is that it ?
I started an integration manual, but I will have to continue on my unix
box, since the rinda tuplespace cannot daemonize on my win32 machine...
(missing fork).
Documentation undergoes small changes all the time. When should I start
commenting the code with what I have in borges.rd ?
Best regards,
kaspar - code philosopher
- -- stolen off the net --
Hello good evening and welcome, to BLACKMAIL! Yes, it's another edition
of the game in which you can play with *yourself*.
-- Monty Python
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFAWxZgh6tlx0BWOuARAi3fAKCw+HE672kWyjnAyps9Y40d3+LdlACfaFo8
7JrLEH3OY1RfVoBQ9DLhAHs=
=P/T5
-----END PGP SIGNATURE-----
-------------- next part --------------
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
***************
*** 119,124 ****
--- 119,160 ----
assert_equal(1, a.contents)
end
+
+ def test_restore_array_as_content
+ a = ValueHolder.new []
+
+ @registry.register(a)
+
+ snap1 = @registry.snapshot
+
+ a.contents << 't'
+
+ snap2 = @registry.snapshot
+
+ @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 = []
+
+ @registry.register(a)
+
+ snap1 = @registry.snapshot
+
+ a << 't'
+
+ snap2 = @registry.snapshot
+
+ @registry.restore_snapshot snap1
+ assert_equal 0, a.size
+
+ @registry.restore_snapshot snap2
+ assert_equal 1, a.size
+ end
end
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
***************
*** 49,54 ****
--- 49,136 ----
# no longer be accessible in their Session history, and no longer
# restorable.
+ class Object
+ def snapshot_shallow_recurse?
+ false
+ end
+
+ def snapshot_dup
+ copy = self.dup
+
+ # check for instance variables that need recursive dupping
+ for var in self.instance_variables
+ v = copy.instance_variable_get(var)
+ if v.snapshot_shallow_recurse?
+ copy.instance_variable_set(var, v.snapshot_dup)
+ end
+ end
+
+ return copy
+ end
+
+ def snapshot_identical_to?(other)
+ for var in self.instance_variables
+ ov = self.instance_variable_get(var)
+ cv = other.instance_variable_get(var)
+
+ # probably recursion needs to be limited to a given level
+ if ov.snapshot_shallow_recurse?
+ unless ov.snapshot_identical_to?(cv)
+ return false
+ end
+ else
+ unless ov.equal?(cv)
+ return false
+ end
+ end
+ end
+
+ return true
+ end
+
+ def snapshot_restore_from(other)
+ for var in self.instance_variables
+ v = self.instance_variable_get(var)
+ o = other.instance_variable_get(var)
+
+ if v.snapshot_shallow_recurse?
+ v.snapshot_restore_from(o)
+ else
+ self.instance_variable_set(var, o )
+ end
+ end
+ end
+ end
+
+ class Array
+ def snapshot_shallow_recurse?
+ true
+ end
+
+ def snapshot_dup
+ self.dup
+ end
+
+ def snapshot_identical_to?(other)
+ return false unless self.size == other.size
+
+ for sv, ov in [self, other].transpose
+ unless sv.equal? ov
+ return false
+ end
+ end
+
+ return true
+ end
+
+ def snapshot_restore_from(other)
+ self.clear
+ other.each_with_index do |e,i|
+ self[i] = e
+ end
+ end
+ end
+
class Borges::StateRegistry
def initialize
***************
*** 60,66 ****
# Register an object in order to keep track of its state.
def register(obj)
! @objects[obj] = obj.dup
end
##
--- 142,148 ----
# Register an object in order to keep track of its state.
def register(obj)
! @objects[obj] = obj.snapshot_dup
end
##
***************
*** 92,98 ****
if snapshot_identical_to(copy, obj) then
snapshot[obj] = copy
else
! snapshot[obj] = obj.dup
end
end
--- 174,180 ----
if snapshot_identical_to(copy, obj) then
snapshot[obj] = copy
else
! snapshot[obj] = obj.snapshot_dup
end
end
***************
*** 105,113 ****
# Restore an individual object's state from a copy.
def restore_object_from_snapshot(object, copy)
! object.instance_variables.each do |var|
! object.instance_variable_set(var, copy.instance_variable_get(var))
! end
@objects[object] = copy
end
--- 187,193 ----
# Restore an individual object's state from a copy.
def restore_object_from_snapshot(object, copy)
! object.snapshot_restore_from(copy)
@objects[object] = copy
end
***************
*** 116,128 ****
# Compare two objects to see if they are identical.
def snapshot_identical_to(copy, object)
! object.instance_variables.each do |var|
! unless copy.instance_variable_get(var).equal? object.instance_variable_get(var) then
! return false
! end
! end
!
! return true
end
end
--- 196,202 ----
# Compare two objects to see if they are identical.
def snapshot_identical_to(copy, object)
! object.snapshot_identical_to?(copy)
end
end
More information about the Borges-users
mailing list