[Zope] Storing un-persistable objects in session (or Zope)
Etienne Labuschagne
etiennel@geospace.co.za
Thu, 15 Feb 2001 11:39:36 +0200
Hi all
I have a COM component that I need to access from Zope. I must either put
this component into a session so that I can carry it around wherever the
user goes OR I must put it into a global object store where I can extract it
whenever I need it.
My problem is: making a class according to Zope's persitence rules does not
work as I get a cPickle.Pickling error (I guess a COM object cannot be
pickled). Saving the creation parameters and instantiating the COM object
every time I need it is really not going to work as the COM object connects
to a remove server and the connection time can be lengthy. I must store the
object in something where it will be accessible for the lifetime of the Zope
service (or some other arbitrary timeout).
Will the following type of solution work (I hate global variables!) or is
that basically all I can do:
In my external method:
objectStore = {}
def GetObject(self,name):
global objectStore
return objectStore[name]
def SetObject(self, name, params):
global objectStore
objectStore[name] = myComObjectWrapper(params) #creates the com object
How will namespaces, module namespaces and multiple threads affect the
accessibility and/or contents of objectStore?
Any help, pointers, etc. would be greatly appreciated.
Regards
Etienne