Log in |
What is Acquisition?Zope and AcquisitionAcquisition is the technology that allows dynamic behavior and content to be passed between Zope objects. Acquisition's flavor permeates Zope, and a basic understanding of acquisition is important for understanding Zope's power and how to harness it. Acquisition is about ContainmentThe concept behind acquisition is simple:
That's it. What's so powerful about Containment?The powerful part about acquisition is how objects automatically gather services from their containers. What this means is that when you create Documents and Folders you're not just building a web site, you're building an information structure. For example, when you place a Document inside a Folder you are creating a small information sharing facility between the Document and the Folder. Why is this different from placing an HTML file inside a directory? Because in Zope, the Document has access to all its container's content and services. So if a Folder can send mail, any Document placed inside the Folder can also send mail. Providing servicesNot only do objects acquire services, they also provide them. For example, adding a Mail Host object to a Folder provides that Folder with the ability to send mail. Documents too can provide services to Folders. In fact every object provides some service. So acquisition goes both ways, when you create an object in Zope it automatically acquires services, and it also automatically provides services that other objects can acquire. This makes reuse of services very easy since you don't have to do anything special to make services available to other objects. Getting Deeper with Multiple LevelsOK, so if you place a Document in a Folder, it acquires the Folder's behaviors. So what happens if things get more complex. Say you have a Document that is inside a couple different Folders. Does it get behavior from its parent, or its parent's parent, or what? The answer is that acquisition works on the entire object hierarchy. If for example you have a Document inside three Folders:
/Users/Barney/Songs/HappySong
The This just seems complex, what's the point? The point is that any given object acquires behavior from not just one object, but
from a collection of objects. This means that it can acquire quite a bit of behavior
and that the behavior can be pretty well tailored to the object. In our
example, the Dynamic BehaviorAcquisition allows behavior to be distributed throughout the system. When you add a new object to Zope, you don't need to specify all its behavior, only the part of its behavior that is unique to it. For the rest of its behavior it relies on other objects. This means that you can change an object's behavior by changing where it is located in the object hierarchy. This is a very powerful function which gives your Zope applications great flexibility. It's not just the objects, but their relation to one another that allows for rich and dynamic content. |