2.1.1.2 Component Interfaces

You can't just hook wires between random parts of your car and expect good results. In the same way, software components can only be ``wired" together if they have compatible interfaces. A software component that expects to send data to a ``file" component must be connected to a component that provides the same services a file would provide, even if the component is not actually a ``real" disk file.

A specific set of services that a component provides is called an interface. Interfaces can denote a component's requirements, as well as the guarantees that it provides when those requirements are met. In PEAK, interfaces are defined and declared using the protocols package, which also supports the use of Zope X3 and Twisted interfaces. This means that components you create with PEAK's component architecture can also potentially work in Zope X3 and Twisted's component architectures. (Which may be useful if you plan to run PEAK applications and web services under Zope X3 or Twisted.)

Interfaces in PEAK are used primarily as documentation and as a way of finding compatible components and services. They can also be used to register adapters (which convert a component from one interface to another), declare web views of application components, and even define security restrictions based on interfaces.

See Also:

Component Adaptation + Open Protocols = PyProtocols
The PyProtocols reference manual has a lot of background information on interfaces, protocols, and adapting components to work with each other. It's also the reference manual for the interface library used by PEAK.
Programming with the Zope 3 Component Architecture
If you're interested in developing Zope X3 applications and want to learn more about what you can do with interfaces in the Zope X3 component architecture, check out this tutorial.
Twisted Components: Interfaces and Adapters
A brief and sometimes amusing look at the basic ideas of interfaces and adapters in Twisted.