[Zope3-dev] Re: "most specific" interface?
Jim Fulton
jim at zope.com
Tue Sep 13 10:17:44 EDT 2005
Jean-Marc Orliaguet wrote:
...
> the idea is that you define as many categories as you need: IMetaType,
> ISomeCategory, IWidgetType ... and you create relations between
> interfaces with:
>
> directlyProvides(IFile, IContentType)
Exactly.
> as if you had a relation tool,
There are all sorts of ways of expressing relationships in Python
without central databases.
> then every object that implements IFile
> (no matter in what position) will have the IFile content type?
Right. Note that a content type is a specific kind of type.
If an object provides interface I, then the object is said to
be of type I. If I is a content type, then the object is said
to have that content type.
As a matter of policy, we expect an object to have a single content
type and have a helper function for getting "the content type" by
finding an object's most specifiuc type that is a content type.
> But where do you put the 'directlyProvides' statement?
There are two options. You put it in some python module, such
as the module that defines IFile:
class IFile(...):
...
directlyProvides(IFile, IContentType)
or, since this is often a configuration choice, you put in in
zcml:
<interface
interface=".interfaces.IFile"
type="zope.app.content.interfaces.IContentType"
/>
Jim
--
Jim Fulton mailto:jim at zope.com Python Powered!
CTO (540) 361-1714 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org
More information about the Zope3-dev
mailing list