Component Architecture Overview
The new component architecture seeks to make developing for Zope easier by clarifying and simplifying the task of extending Zope. Radical as this change may sound, it is in fact more philosophical than architectural. Most of the changes we propose for Zope are just new patterns for developing with Zope.
The new component architecture will continue to be backwards compatible with the "old" way of doing things. While we don't guarantee backward compatibility forever, rest assured that Zope is not changing radically.
Here is a brief high level overview of Zope's new component architecture. For more background on why components are a good thing, see ComponentArchitectureApproach.
A component is an object with introspectable interfaces. An interface is an object that describes how you work with a particular component. Really, it doesn't matter how the component is implemented, the important part is that it comply with its interface contracts.
Because of this, different components can assert the same interface, but be implemented in different ways. For example, you could have a two different "Document" components, one that stored its contents in a database, and one that stored its contents in a file. It doesn't matter which kind you use, as long as you implement the "Document" interface. Any tool designed to work with one component will work seamlessly with the other.
The simplest kinds of components are Content Components. Content components are components that are designed to hold data or "content". For example, Document, and Image are examples of content components.
Content components are very simple, they generally only define an interface for controlling their content. They don't provide interfaces for doing application specific things (like, for example, mailing the content to another person) nor do they provide user interfaces like HTML pages.
Factory components are components that create other components. For the most basic Zope component development, you will only need to create two kinds of components: a content component, and a factory component to create instances of that content component. Factory components are typically easy to implement (after all, their only task is to create another component).
Once you have created a content component and a factory component you can begin to immediately use your component in Zope through Python Scripts (which already come with Zope). Your component will not, however, have any kind of web management interface. For that, you need to create a Presentation Component.
View components provide a user interface to other components. The most common pattern is to create a view component that presents (or provides a "user interface" for) a content component. An example of view components that can be used with Zope are Zope Page Templates (ZPT). Page templates are only about presentation, and should not contain any kind of application-specific logic. For example, you could create a "Show" view component that displayed your "Document" content component in HTML.
However, view components and content components may not do everything you need to develop your application. If you wish to extend your content component to have more advanced behavior (other than just storing content) you can extend them with Adapter Components.
Adapter components sit between content components and view components. Typically, they are used to provide application specific functionality to your content components.
For example, your "Document" content component may have an
edit() method, but it does not have a
method that you need to satisfy your requirements. Instead of
changing the content component or the view component, new
application specific features are added by creating an adapter
Content, Factory, View and Adapter components are the four most common kinds of components. There are two other kinds, however, that will be available to you. These are Utility and Service components.
Utility components are components that serve only one specific function, and are not designed to act on another component. A good analogy for Python programmers are functions and methods. Utility components, like Python functions, are standalone objects that do not need any other objects to do their work. Adapter components, like Python methods, require another object to work upon.
Utility components will mostly be used for simple, throw-away components that serve one simple task, like an XML parser.
The last kind of component is a Service Component. Services are a small set of core functionality provided by the Zope platform. These can be thought of as the "kernel" that Zope provides for your web applications. Services we anticipate existing in Zope include user sessions, authentication, workflow, content-type management, and even managing your components themselves.
The new Zope component architecture promises to provide a simple web application environment that is both simple to learn and easy to use.
french translation --zopeur, 2004/04/14 20:07 EST reply
I have dropped a french translation of this document here : http://zope.org/Members/zopeur/Document.2004-04-14.5532
... --lidong, Tue, 30 Dec 2008 03:51:47 -0500 reply
I have dropped a Chinese translation of this document here http://www.zope3.cn/Wiki/ComponentArchitectureOverview
... --lidong, Tue, 30 Dec 2008 03:52:13 -0500 reply