[Zope] Re: How do I update objects?

Dylan Reinhardt zope@dylanreinhardt.com
Mon, 17 Feb 2003 08:31:22 -0800


At 04:58 AM 2/17/2003, Oliver Marx wrote:
>I would like this newProperty to have the value aq_parent.title. But
>
>newProperty = Implicit.aq_parent.title
>
>Does not work. Can it be done?

Since this is a custom product, there may be an easier way to do this:

Make newProperty a class attribute instead of an instance property:
----------
# top of head, untested

from Acquisition import aq_parent

class foo(various_base_classes):
    ...
    def my_parent_title(self):
       try:
          return aq_parent(self).title
       except:
          raise 'AttributeError', '%s has no parent or the parent has no 
title' % self.id

    newProperty = self.my_parent_title
----------
That way, all you'll have to do to get this attribute is refresh the 
product... no updating necessary.  Also, even if an instance gets moved, 
your attribute should return correctly.

HTH,

Dylan