Python properties can not use acquisition?

Bug #143756 reported by Christian Theune
2
Affects Status Importance Assigned to Milestone
Zope 2
Won't Fix
Medium
Unassigned

Bug Description

I was trying to use a property in Zope 2.9 lately in a Plone/CMF-related product. I was trying to access a portal tool via getToolByName in the property and found that 'self' was not acquisition-wrapped in the getter of the property.

Tags: bug zope
Revision history for this message
Florent Guillaume (efge) wrote :

No, self is not wrap in a property.
But you can use instead:

from ComputedAttribute import ComputedAttribute
class Foo(object):
    def barMethod(self):
        pass
    bar = ComputedAttribute(barMethod, 1)

The 1 is important, it's a level of wrapping (see the ComputedAttribute code).

Why is this question in the bugtracker exactly? I should think that's what dev lists are for.

Revision history for this message
Tres Seaver (tseaver) wrote :

Status: Pending => Wontfix

Can't fix it -- Python's property implementation is not
friendly to the kind of trickery we do in acquisition.

Florent's suggestion (using ComputedAttribute) is the correct
workaround for your case.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.