From: Steve Tuckner Date: 2003-08-08T00:26:19+09:00 Subject: [DRb] Using DRb to implement object database This is a multi-part message in MIME format. ------=_NextPart_000_000B_01C35CCE.4FC450B0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit 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 ------=_NextPart_000_000B_01C35CCE.4FC450B0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hello = all,
 
I am = try to=20 implement a simple object database where one process is a DRb server = that holds=20 the objects in the database and uses pstore to save/restore the = database. In my=20 client program I want to create an object that I then want to put into = the=20 database. So for example here is a simple class:
 
class = Foo
   =20 attr_accessor :x,:y
 
   =20 def initailize(x,y)
        = @x, @y =3D=20 x,y
   =20 end
end
 
On = the client I=20 create an object from that class:
 
foo = =3D=20 Foo.new(1,2)
 
I = connect to the=20 database (it is a simple array)
 
DRb.start_service()
object_database =3D=20 DRbObject.new(nil, "drb://localhost:9000")
 
I put = the object=20 into the database
 
object_database.push(foo)
=
 
Now = If I modify the=20 object locally
 
foo.x = =3D=20 4
 
It = only modifies it=20 locally (the object on the DRb server is unmodified)  If I instead = get the=20 object back from database
 
bar = =3D=20 object_database[0]
bar.x = =3D=20 5
 
bar = is still just=20 local.
 
Now = If I include=20 DRbUndumped in class Foo, then my changes are available at the server = and=20 another client can see them. However, when I go to save the object with = pstore,=20 it doesn't save something of class Foo, it saves a DRbObject because = the object=20 still really only exists in the client and is proxied at the=20 server.
 
If I = do the=20 following to create foo at the server (assume pusheval does the eval at = the=20 server):
 
object_database.pusheval("Foo.new(1,2)")
 
Now = the object at=20 the server is of class Foo and if I get it on the client it is a = DRbObject (thus=20 proxied). I can set the values on the client and they happen on the = server.=20 Great!
 
Unfortunately, I can=20 no longer save the object because module DRbUndumped is the=20 following:
 
  module=20 DRbUndumped
    def=20 _dump(dummy)
      raise TypeError, 'can\'t = dump'
    end
  end
And = so pstore can't=20 dump it to the disk.
 
Any = ideas of how I=20 should do this?
 
Thanks in=20 advance,
 
Steve = Tuckner
 
------=_NextPart_000_000B_01C35CCE.4FC450B0--