[Zope-dev] Re: ComputedAttribute

Martijn Pieters mj@digicool.com
Thu, 11 Jan 2001 08:57:31 +0100


On Wed, Jan 10, 2001 at 11:09:43PM +0100, Dieter Maurer wrote:
> Chris Withers writes:
>  > Now I think I know the answer to this one, but I'll ask just to be sure:
>  > 
>  > class MyClass(Persistent Acquisition.Explicit):
>  > 
>  >      def _set_your_attribute (self,value):
>  > 	self._v_your_attribute = value
>  > 
>  >      def _get_your_attribute (self):
>  >          return self._v_your_attribute
>  > 
>  >      your_attribute = ComputedAttribute(_get_your_attribute)
>  > 
>  > ....with this class, your_attribute isn't going to play in Persistence,
>  > is it? (so I can update it lots without worrying about ZODB size
>  > growing... :-)
> But, as I understand it, it is only updated in the thread
> that did the update. Your next request may get a different
> thread and see a different value.

Indeed, only persistent variables are shared between threads (and globals
of course, which creates a need for some kind of protection).

-- 
Martijn Pieters
| Software Engineer  mailto:mj@digicool.com
| Digital Creations  http://www.digicool.com/
| Creators of Zope   http://www.zope.org/
---------------------------------------------