[omniORB] omniORBpy: Pickling Objects

Duncan Grisby dgrisby@uk.research.att.com
Fri, 14 Jan 2000 16:30:11 +0000


On Friday 14 January, Robert Sander wrote:

> I am working with omniORBpy and ZOPE (www.zope.org), which is
> mainly a object database. The ZOPE mechanism relies on
> pickling the objects to store them. For now, the storing
> of CORBA objects is not possible, because they have no pickle
> interface. Could that be made possible? IMHO it is only
> necessary to store the IOR string retrieved by
> orb.object_to_string when pickling. At unpickle the IOR must
> be resolved, but that should work if the object on the other
> side is still alive.

The following patch allows pickle to work for object references. Note
that if you hold a reference to an object in your own address space,
pickling the object reference just pickles the reference, not the
servant object itself. This may or may not be what you expect.

Any comments?

Cheers,

Duncan.

RCS file: /project/omni/cvsroot/omniORBpy/python/omniORB/CORBA.py,v
retrieving revision 1.15
diff -u -r1.15 CORBA.py
--- CORBA.py	1999/12/07 12:35:33	1.15
+++ CORBA.py	2000/01/14 16:27:48
@@ -586,6 +586,15 @@
     def __del__(self):
         pass
 
+    def __getstate__(self):
+        return ORB_init().object_to_string(self)
+
+    def __setstate__(self, state):
+        o = ORB_init().string_to_object(state)
+        self.__dict__.update(o.__dict__)
+        def dummy(): pass
+        o.__del__ = dummy
+
     def _get_interface(self):
         # ***
         raise NO_IMPLEMENT


-- 
 -- Duncan Grisby  \  Research Engineer  --
  -- AT&T Laboratories Cambridge          --
   -- http://www.uk.research.att.com/~dpg1 --