[Product-Developers] Re: @property strips acquisition context

Martin Aspeli optilude+lists at gmail.com
Tue Sep 1 00:52:22 UTC 2009

David Glick wrote:
> On Aug 31, 2009, at 8:15 AM, Hedley Roos wrote:
>> Hi
>> I have a Dexterity custom class. I decorate a method foo with  
>> @property
>> but inside the method 'self' is not acquisition wrapped anymore. I'm
>> sure the object is wrapped before my attempt to access ob.foo
>> I'm sure it is not related to Dexterity but I mention it in case.
>> So the question is: should I be surprised that it is not working?
> This is a known side effect of the @property decorator.  Not sure what  
> the best workaround is.  Anyone?

The best workaround is to not depend on acquisition. :)

The other workaround is to use a ComputedAttribute.

The third workaround is to do something like:

 >>> from zope.app.component.hooks import getSite
 >>> site = getSite()

The 'site' object is now the aq-wrapped portal root, from which you can 
acquire stuff.


Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book

More information about the Product-Developers mailing list