[Zope] persistent object with non-persistent attributes

sean.upton@uniontrib.com sean.upton@uniontrib.com
Tue, 04 Mar 2003 10:50:34 -0800


Thinking aloud: ...so myNonZopeClass instances need to be a singleton-like
thing, with some sort of mutex-ish of lock to prevent other instances from
being constructed?  I wonder if there is a way to throw an exception on
construction of a myNonZopeClass instance if another Zope thread has an
instance.  Perhaps you could keep an external boolean lock variable in a
module-level global accessible to all threads, but it might just be easier
to follow Toby's suggestion and just see if you can keep your myNonZopeClass
instance object in a module-level global, and just keep a reference to it in
a _v_ attribute?  I've never tried anything like this, might something like
this possibly work?

Sean

-----Original Message-----
From: Jerome Alet [mailto:alet@librelogiciel.com]
Sent: Tuesday, March 04, 2003 2:15 AM
To: Toby Dickenson
Cc: zope@zope.org
Subject: Re: [Zope] persistent object with non-persistent attributes


On Tue, Mar 04, 2003 at 09:30:53AM +0000, Toby Dickenson wrote:
> On Tuesday 04 March 2003 9:22 am, Jerome Alet wrote:
> 
> Zope uses (by default) four publishing threads. That means you will get
four 
> copies of your objects in memory at any one time (or 8, if you have 2 zeo 
> clients). You also have the possibility of ZODB choosing to deactivate
your 
> object, so all attributes are lost from all 4 of those objects.
> 
> 'hardware plug&play' makes me think this is this what you want... Perhaps 
> storing this special object in a module-level global would be better?

but I must be sure that only one thread deals with the hardware at
a time.

> >   myZopePersistentClassInstance.complexAttr = myNonZopeClass()
> >
> > but this will probably, if it works, bloat by ZODB.
> >
> > is there a way to do this without suffering from severe bloat ?
> 
> myZopePersistentClassInstance._v_complexAttr = myNonZopeClass()
> 
> will exclude that attribute from ZODB processing.

This is perfect ! But now how can I be use that no other thread
access the hardware at the same time ? (if possible a single
device open at Zope start or on-demand would be fine)

I actually use a CGI script for this, but I wondered if using
Zope instead wouldn't make it more "reactive".

Thanks in advance.

Jerome Alet

_______________________________________________
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )