[Zope-dev] Developers Reference

Chris Withers chrisw@nipltd.com
Fri, 05 Jan 2001 13:18:34 +0000


Anyone know if there are plans for a second O'Reilly book to cover
development stuff like this?

. o O ( Zope: The Definitive Developers Reference )

Ah, I guess I can only dream for now :-)

cheers,

Chris

Martijn Pieters wrote:
> 
> On Fri, Jan 05, 2001 at 12:22:32PM +0000, Chris Withers wrote:
> > Martijn Pieters wrote:
> > >
> > > You could use ComputedAttribute for that:
> > >
> > > class MyClass(Acquisition.Explicit):
> > >     # The following attribute is acquired transparently
> > >     def _acquired_your_attribute(self):
> > >         return self.aq_acquire('your_attribute')
> > >     your_attribute =        ComputedAttribute(_acquired_your_attribute, 1)
> > >
> > >     # index_html isn't
> > >     index_html = None
> >
> > That looks cool :-)
> >
> > Where's it documented? what does the 1 mean?
> 
> Erm. The ExtensionClass.stx documentation hints at a ComputedAttribute
> class (but as an example of how you could use an ExtensionClass). The
> current C implementation of ComputedAttribute is not, as far as I can see,
> documented.
> 
> As for the '1', the CVS log has the following to say on that:
> 
>   Added second "level" argument for computed attributes.  This makes it
>   easier to create computed attributes that work with acquisition.
>   Normally, computed attributes are called with unwrapped objects. Passing
>   a level of 1, causes computed attributes to be called with one level of
>   wrapping.  Note that the innermost (single) level of wrapping typically
>   reflects a containment context with any extra access contexts stripped
>   off.
> 
> As I understand it, it makes self.aq_acquire possible.
> 
> See also:
> 
>   http://cvs.zope.org/Zope2/lib/Components/ExtensionClass/ComputedAttribute.c
> 
> --
> Martijn Pieters
> | Software Engineer  mailto:mj@digicool.com
> | Digital Creations  http://www.digicool.com/
> | Creators of Zope   http://www.zope.org/
> ---------------------------------------------
> 
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope )