Which part of Zope cares about interfaces in Products?
Hi. I'm trying to learn how to code Plone products using Archetypes, but to get a sound understanding, I'm going through layer by layer, starting from Zope products written in Python. I have been trying Plone for about 6 months. My Python experience is very limited. In Zope Developer's guide at zope.org, it says that when you make products you should define the interface of your product and make the implementation class implement that interface. I understand that this "interface" is not a built in feature of Python, but a convention introduced by Zope. By following the convention, you get some introspection capabilities that is provided by Zope libraries. From my experience with OOP in Java and C++, using interfaces makes sense only when some code knows that interface and codes against it, or some introspection based tool (typically a GUI builder or RMI/CORBA-ish tool) will study your interface and do something based on that knowledge. What is not clear to me is the effect of declaring the interface of Zope products. How does Zope care about it? In "The definitive guide to Plone", the product example does not define it's own interface, but does assert that it implements some interfaces that are defined by the framework. So it seems that it is not necessary to define the inteface of your product to make it work, but still meaningful to assert that it implements some well-known interfaces. The Zope Developer's guide does not actually say that you must define interfaces to make your product work. It just says that doing so will make it easier for other people to understand your products. If that is the sole effect of using interfaces, it is just for documentation, then. Am I right? -- Hideo writing from Yokohama Japan.
On 11/8/05, Hideo at Yokohama <hideo.at.yokohama@gmail.com> wrote:
The Zope Developer's guide does not actually say that you must define interfaces to make your product work. It just says that doing so will make it easier for other people to understand your products. If that is the sole effect of using interfaces, it is just for documentation, then. Am I right?
Short answer: Yes. Long answer: Mostly, but not quite, and this is changing rapidly. :) Really long answer: There are parts of Zope that cares about if a class or an object implement a certain interface. In Zope 2, up until quite recently, interfaces was mostly used to filter out objects. For example, you can create an object that only lists objects that implement a certain interface in the Add list. If you go to the Indexes-tab in a ZCatalog, this is an example of that. In Zope3, however, interfaces are the basis of everything. Starting with Zope 2.8 a technology called "Five" is being used to step by step move the Zope3 programming paradigm into Zope 2. So, with Five, interfaces are extremely important. -- Lennart Regebro, Nuxeo http://www.nuxeo.com/ CPS Content Management http://www.cps-project.org/
participants (2)
-
Hideo at Yokohama -
Lennart Regebro