[Zope] Getting aquisition values from object attribute

Johan Carlsson [EasyPublisher] johanc@easypublisher.com
Mon, 24 Mar 2003 11:18:48 +0000


At 12:01 2003-03-24 +0100, Max M said:
>I have a product which has an object attribute that is an object. Just 
>like HTMLFile() or similar.
>
>I need to get the aquisition values from the parent object. How on earth 
>do I do that?
>
>Pseudocode
>
>class MyAttr:
>
>    def title(self)
>        "I need to get ie. title value from 'MyProduct'"
>        return # ?????
>
>
>class MyProduct:
>
>    my_attr = MyAttr()

I addition to You may need using Acquisition.Implicit
you might need to use aq_parent. Or remove the title method alltogether.

from Acquisition import Implicit, aq_parent

class MyAttr(Implicit):

    def title(self)
        "I need to get ie. title value from 'MyProduct'"
        return aq_parent(self).title


class MyProduct:

    my_attr = MyAttr()


Regards,
Johan Carlsson



-- 
Easy Publisher Developers Team
Johan Carlsson
johanc@easypublisher.com

Mail:
Birkagatan 9
SE-113 36  Stockholm
Sweden

Phone +46-(0)8-32 31 23
Fax +46-(0)8-32 31 83
Mobil +46-(0)70-558 25 24
http://www.easypublisher.com