[Zope3-dev] Re: PythonProgrammerTutorial: questions, comments, and feedback

Shane Hathaway shane@zope.com
Sat, 08 Dec 2001 23:27:39 -0500


Jim Fulton wrote:

> Joseph Wayne Norton wrote:
>>  - CMF implemented the idea of a zope object having a "Type" and
>>    "meta-type".  How does this compare with Zope3?
> 
> I'm gonna let Tres or Shane answer this one. :)


This is an important detail--thanks for asking, Joseph.  We struggled 
with this early on in our discussions of the component architecture.  We 
first figured out why they're so useful: CMF "Types" give you the 
ability attach a simple label to objects and then connect varying 
application functionality to a common implementation.  It turns out to 
be very useful to be able to reuse CMF documents as articles, postings, 
comments, etc.  You can write many applications without having to fall 
back to Python products or ZClasses.

But it turns out that an object having multiple types can be confusing. 
  Paul and Jim expressed the desire that both "meta_type" and 
"portal_type" be expressed as interface assertions.

That is certainly a good thing, because for one thing the simple 
meta_type string has led to several clashes (how many "Image" meta_types 
are out there?)  But when it comes to changing the portal_type attribute 
to an interface assertion, things get a little tricky: now we'll have 
interface assertions on not just classes, but also instances!

So I added some tentative code to the Interface package that should make 
interface assertions on persistent instances possible.  It lets you 
declare "this instance implements label interface X as well as all the 
interfaces asserted by its class".  It also lets you pickle interfaces 
the same way you pickle classes, though the way it currently achieves 
that is a little hackish.  It tricks ZODB.

Anyway, the bottom line is that CMF types will be replaced with "label 
interfaces" on instances.  I think it will surprise people a little but 
its flexibility will be even greater than what CMF gives you today. 
You'll be able to provide components for label interfaces.

Shane