Z Object Publishing Environment
Search 
 

 Guest


Log in

 Zope Exits


Technocrat.net
Appwatch.com
CodeCatalog.com

How-To: What is Acquisition?

Zope and Acquisition

Acquisition 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 Containment

The concept behind acquisition is simple:
    Objects are placed inside other objects.

    Objects acquire content and behavior from their containers.

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 services

Not 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 Levels

OK, 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 it's parent, or it's 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 HappySong Document acquires behavior from the Songs Folder. And the Songs Folder acquires behavior from the Barney Folder, and so on.

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 Songs Folder might provide behavior which is appropriate for song Documents like how to draw musical notes. On the other hand, the Users Folder might provide more general behavior which is appropriate for Documents owned by users, such as access controls to ensure that only the Document's owners can modify them. Zope composites these acquired services together so that objects acquire a rich pallet of services.

Dynamic Behavior

Acquisition 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. 

 
 
Privacy policy       Printable Page       Feedback to this page's author      Feedback about Zope.org