An important topic for Zope developers. It basically means that Zope can "see" any object that is in the current ZODB (Zope Object Database) folder, or any of the parent folders up to the root, where "parent" means both "the folder containing this one" and "the folder previously referenced in the url".
This can be very convenient, eg objects in many folders can "acquire" customizations from a single template in a parent folder. The precise details of how this works will make your head spin; try not to get involved.
See
- Zope 2 Book: Zope Concepts and Architecture
- Zope 2 Book: Acquisition
- Shane's Acquisition Understander
- Zope 2 Developer's Guide discussion of acquisition
- ZopeTips
- ZopeLabs
Here is an evolving set of links to postings which describe the Zen of Acquisition. It is mainly targeted towards how acquisition works within Python.
- How to determine what objects can be added to a folderish object
- Reference: http://lists.zope.org/pipermail/zope-dev/1999-November/002334.html .
The all_meta_types attribute is used to determine what can be added to a folder. lib/python/ZClasses/Property.py uses the following construct
meta_types=( Globals.Dictionary(name=ZCommonSheet.meta_type, action=manage_addCommonSheetForm), )def all_meta_types(self): return self.meta_types
- How Zope finds out the contents of a folder as it walks up the tree
- Reference: http://lists.zope.org/pipermail/zope-dev/1999-November/002328.html .
When looking for objects which cannot be found within the current folder it calls the following functions recursively until it finds it: __bobo_traverse__, then __getattr__, then __getitem__. If you don't want to acquire attributes from the parent object then add Acquisition.Explicit to your inheritence chain before any folderish objects.
These functions then call the aq attributes to determine where to look for the missing attributes: aq_parent, aq_base
- How to get your Python base class to inherit from a Zclass
- Reference: http://lists.zope.org/pipermail/zope-dev/1999-November/002322.html
No solution for this problem has been found.
- How to "acquire" an object "in the context of" another object so that it can acquire attributes from that object
- Reference: http://lists.zope.org/pipermail/zope-dev/1999-November/002051.html
child = self.children!name return child.__of__(self)(The last line can be read "Return child in the context of self"). - How to change the order in which Zope checks the acquisition parameters. This allows you to implement your own __getattr
- Reference: http://lists.zope.org/pipermail/zope-dev/1999-November/002150.html
Basic technique is overriding __of__ to put a wrapper around the object hence not overwritting the actual __getattr__ of the object, only that of the wrapper
- How to perform an operation when the object is retrieved from the database into memory, as opposed to when Zope starts up
- Reference: http://lists.zope.org/pipermail/zope-dev/1999-November/002176.html
Basic technique is to add a __setstate__(self, state) function to your class
- How to change what your Zclass returns when it is called via <dtml-var myattribute>
- Reference: http://lists.zope.org/pipermail/zope-dev/1999-November/002208.html
Override the __str__ attribute.
- Understanding some basics of how acquisition works (wrappers and container VS context)
- Reference: http://soyouwillfindit.blogspot.com/2009/04/understanding-zope-acquisition.html