Explanation of why an unofficial patch for _aq_dynamic support in Zope is required
Table of Contents
If an object does not have an attribute but has the method _aq_dynamic, _aq_dynamic
is called in the context of the object when acquiring the attribute. The method
_aq_dynamic must return None if an attribute is not found, otherwise return an
acquired value. A call to _aq_dynamic happens before acquiring an attribute from
the parent, and after trying to get the attribute from the object itself. ERP5
uses _aq_dynamic to generate methods automatically, based on definitions in the
file system, definitions in the portal, etc. For example, property accessors
(such as getQuantity) are generated in this way. Because ERP5 supports TTW
(Through the Web) development and customization, it is very important that
_aq_dynamic is called with the information on a portal site, so that the user
can set custom properties, categories, and so on on portal_types.
There are some ways to implement a similar feature. http://zopewiki.org/Acquisition
describes some ideas. But they are not sufficient for our purpose.
Only because we don't get along with the developmental version of Zope yet.
Currently, our focus is more on improving the stability of ERP5 with the current
set of installations. Certainly, we should discuss how to make the patch go into
the official version with Zope developers, once we are ready for moving to the
latest version of Zope.
If an object is not an acquisition wrapper, nothing changes.
If an object has an attribute in itself, nothing changes.
If an object does not have an attribute, and if the object does not have
_aq_dynamic, only one attribute lookup is performed. The performance penalty is
If an object does not have an attribute, but has _aq_dynamic, this method is
called. Since this method is called every time when getting the same attribute,
as long as the object does not define the attribute, _aq_dynamic should set the
attribute on the object or its class at the first call, and should avoid
evaluating a complex expression at the second call and later.