[Zope] Re: Archetype or Product inheritance
Max M
maxm at mxm.dk
Wed Sep 29 18:55:33 EDT 2004
Dieter Maurer wrote:
> Bryan Simmons wrote at 2004-9-28 21:41 -0400:
>
> I do not think the "__implements__" does anything beside
> a bit of documentation and support for a lookup by interface
> during factory lookup (only used to create indexes, AFAIK)
I know I am slow, but a few days ago it finally dawned on me what the
biggest advantage of the use of interfaces is, and it is freakin brilliant.
In Zope we had the meta_type to represent an objects "type". Kind of
like a column name in an sql database.
So in CMF/Plone we have the portal_type, which does something similar.
But not quite. Portal types were orginally meant to be like meta types
that could be set on individual instances.
The problem is then, if I want to make a list of all "folders" in my
site, I can make a query like:
zope_folders = catalog(meta_type='Folder')
plone_folders = catalog(portal_type=('Folder', 'BTreeFolder2',
'CMFFolder', )) # etc.
all_folders = zope_folders + plone_folders
But this is error prone, and if a new type of folder is installed on the
site, it will not automatically appear in my search.
But if instead I can check if an object implementes the "Folder"
interface, any new folder types will automatically be added in my
searches. Something like this perhaps?
all_folders = catalog(implements='Folder')
This will make it a lot easier to integrate new content types in the system.
I know this is a blinding flash of the obvious for Zope 3 developers,
but it was a nice discovery for me.
I had gotten the notion that interfaces were for documentation purposes
only.
--
hilsen/regards Max M, Denmark
http://www.mxm.dk/
IT's Mad Science
More information about the Zope
mailing list