[Zope] Storing unpicklable objects

Li Dongfeng mavip5@inet.polyu.edu.hk
Fri, 03 Sep 1999 14:58:09 +0800


Question: can we store an arbitrary python object
 (created with external method) in the ZOPE namespace
 during the life of the current ZOPE server process?

If the object is picklable, then we just assign it to an
attribute of a folder. The object will survive pickling.

But if the object is not picklable, e.g., an open pipe,
or an open file, then Zope does not allow it to be
assigned to a normal attribute. The solution I used now
is to assign the object to an attribute with name starting
with _v_, like _v_my_sub_process_pipe. Then the object
can be saved, for some period of time, and can be used
by other external methods(other than the one created it).
But, after a while, the saved _v_ attribute simply dispears.
I guess it has been saved to the ODB and then reloaded, but attributes
with _v_ name prefix cannot survive pickling, so it is lost.

Zope gurus: is there any way to allow saving of arbitrary
 python object in the running Zope process? I only need
 the object to live during the server process's life.

I need this feature because I'm driving a interactive R
process with Zope, users(using web browsers) can submit
R programs to the Zope server and get result from Zope.
For this, I have a Pipe3 object linked with the R
subprocess, if only I could get hold of this Pipe3 object
during the server's lifetime, I can interact with it.

If other Zope developers want to drive an interactive subprocess
through wb server and let web client access the subprocess,
this is a general problem we need to solve.

Jim Fulton <jim@digicool.com> has mentioned some solution
in the previous "Persistent method" thread, but I can't quite
understand how to accomplish the task with the current version
of Zope.