Hello all,
I am try to implement a simple object database where one process is a
DRb server that holds the objects in the database and uses pstore to
save/restore the database. In my client program I want to create an
object that I then want to put into the database. So for example here is
a simple class:
class Foo
attr_accessor :x,:y
def initailize(x,y)
@x, @y = x,y
end
end
On the client I create an object from that class:
foo = Foo.new(1,2)
I connect to the database (it is a simple array)
DRb.start_service()
object_database = DRbObject.new(nil, “drb://localhost:9000”)
I put the object into the database
object_database.push(foo)
Now If I modify the object locally
foo.x = 4
It only modifies it locally (the object on the DRb server is unmodified)
If I instead get the object back from database
bar = object_database[0]
bar.x = 5
bar is still just local.
Now If I include DRbUndumped in class Foo, then my changes are available
at the server and another client can see them. However, when I go to
save the object with pstore, it doesn’t save something of class Foo, it
saves a DRbObject because the object still really only exists in the
client and is proxied at the server.
If I do the following to create foo at the server (assume pusheval does
the eval at the server):
object_database.pusheval(“Foo.new(1,2)”)
Now the object at the server is of class Foo and if I get it on the
client it is a DRbObject (thus proxied). I can set the values on the
client and they happen on the server. Great!
Unfortunately, I can no longer save the object because module
DRbUndumped is the following:
module DRbUndumped
def _dump(dummy)
raise TypeError, 'can’t dump’
end
end
And so pstore can’t dump it to the disk.
Any ideas of how I should do this?
Thanks in advance,
Steve Tuckner