Archetype or Product inheritance
Hi all, Suppose I have a zope product, or an Archetype-based content-type, like ATEvent. If I use __implements__ to define another content-type, will my new content-type inherit the ATEvent schema? That would fit true polymorphism and I would expect zope to conform truly to OOP. I'm hoping this is correct because it would make development a lot swifter (better to build upon something already tested and stable). -- Regards, Bryan Simmons -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. -- Rick Osborne -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Bryan Simmons wrote at 2004-9-28 21:41 -0400:
Suppose I have a zope product, or an Archetype-based content-type, like ATEvent. If I use __implements__ to define another content-type, will my new content-type inherit the ATEvent schema?
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) It does not control schema extension... Instead, you would define a new Archetype class and use class MyNewATClass(BaseClass1, BaseClass2, ...): schema = schema1 + schema2 + ... + Schema(...) The "schema_i" can be schemas from base classes or from somewhere else. -- Dieter
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
participants (3)
-
Bryan Simmons -
Dieter Maurer -
Max M