ERP5 requires an unofficial patch for _aq_dynamic support in Zope. The patch adds this functionality:
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.
Table of Contents
There are some ways to implement a similar feature. http://zopewiki.org/Acquisition describes some ideas. But they are not sufficient for our purpose.
Basically, this method is to tweak the traverse of an URL. This method is not used when getattr is used, for example.
__getattr__ is a good candidate, because it is called only if an attribute is not found, and the semantics is quite similar to _aq_dynamic. However, __getattr__ is called with aq_base, that is, self is not an acquisitoin wrapper when called. So it is not possible to get information about a portal site.
This method is called too early. It is even before acquisition wrapping.
This method is called too early, too. Because this method is called when getting an object, the state of the object is not always fully integrated into a portal site.
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 negligible.
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.