[Zope-dev] In-memory persistence of non-serializable objects?

Shane Hathaway shane@zope.com
Mon, 06 Aug 2001 11:16:24 -0400


Michael Strasser wrote:
> I want to create a Zope object that can keep non-serializable objects
> (specifically sockets) in memory between requests.
> 
> The idea is (in its simplest form):
> 
> * On first request to the object a socket is opened and stored.
> * On subsequent requests the same socket is used. If one of these
>   requests is to close the socket it is closed. If the socket has
>   been closed by the other end an error is returned.
> 
> I haven't found information about in-memory persistence of Zope objects and
> non-serializable objects can't be stored in ZODB. Have I missed something
> obvious?

It depends on whether you want the sockets to be shared between threads. 
  If you do, put them in a module-scope dictionary keyed by _p_oid.  If 
you don't, use a volatile attribute.  Any attribute with a name that 
starts with "_v_" is a volatile attribute and is not stored in ZODB.

Shane