[Zope-dev] aq_parent not available in __setattr__

Chris McDonough chrism@zope.com
Wed, 6 Feb 2002 02:43:49 -0500


Question: do you really need to use the __setattr__ hook to track changes=
 to
the object?  Is the application written in such a way that you could expo=
se
a different API?  __setattr__ is special because it's provided by the
persistence machinery to track object changes.  Overriding it is possible=
,
but it's slightly black-magic (it used to be impossible to override it, b=
ut
that changed about a year ago or so with caveats).

If it's still desirable, you might be able to do something like this via =
a
combination of overriding Acquisition's __of__ method, volatile attribute=
s,
and a special-purpose __setattr__ .  See CMF's Skinnable.py for an exampl=
e
of doing this with __getattr__.

----- Original Message -----
From: "Brian Oliver" <beef005@hotmail.com>
To: <dieter@handshake.de>
Cc: <zope-dev@zope.org>
Sent: Tuesday, February 05, 2002 8:19 PM
Subject: Re: [Zope-dev] aq_parent not available in __setattr__


Yep... Certainly isn't.

Aquisition isn't available for either __getattr__ or __setattr__.

So the fundamental question remains...

How does one receive a callback/create a hook that is called when an
attribute is changed, especially changed via the default property editor =
for
Zope objects (such that aquisition still works)?

If this type of feature isn't already planned for Zope 3 (I'll take a loo=
k
and get active), I'm sure it should be.  My suggestion would be to provid=
e
Java Beans like get and set methods for all properties, so custom handler=
s
could easily be created.

-- Brian


>From: Dieter Maurer <dieter@handshake.de>
>To: "Brian Oliver" <beef005@hotmail.com>
>CC: zope-dev@zope.org
>Subject: Re: [Zope-dev] aq_parent not available in __setattr__
>Date: Tue, 5 Feb 2002 23:08:13 +0100
>
>Brian Oliver writes:
>  > ...
>Share reported for "__getattr__" (--> mailing list archives)
>that the self passed in is not acquisition wrapped.
>Maybe, this is also the case for its companion "__setattr__"...
>
>
>Dieter




_________________________________________________________________
Join the world=92s largest e-mail service with MSN Hotmail.
http://www.hotmail.com


_______________________________________________
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 )