[Zope-CMF] Re: Easiest way to make my own portal_type that is like CMFDocument but with extra properties

Tres Seaver tseaver@palladion.com
Sat, 18 Aug 2001 18:39:48 -0400


Lynn Walton wrote:

> Oh ... sorry one more question I should have asked as part of this
> question:  I'm not sure when properties and metadata are the same or not.
> On Portal Products are all properties metadata?  If I want each document to
> have different values for 3 set "properties/attributes" and I probably would
> want to be able to use them in searching/cataloging  should they be metadata
> or just properties or are they one an the same?  Thanks for bearing with my
> newbie questions.  Thanks to everyone's help I am learning a lot and hope to
> start being able to "give back", with all the knowledge I'm soaking up. : )
> 
> Lynn
> 
> Lynn Walton wrote:
> 
> 
>>Can someone advise me on what the easiest way would be to create
>>my own portal product that is like CMFDocument but with extra properties
>>?
>>
>>I've read the beehive CMF chapter that shows how to alter an existing
>>one (main idea copied below to show what I'm referring to...)  ... but
>>not sure if/how using that way I'd add my own properties.
>>
>>-----------
>>>From ZWACKChap5.html
>>There are a couple of ways to create a new type depending on what kind
>>of type you want to create. If you want to create a type that is only
>>slightly different than one that already exists, e.g. if you want to
>>change the name and representation of a type, you base your new type on
>>the existing one.
>>
>>Using an Existing Type to Create a New One
>>
>>In this section, we will create a new portal type called CV which will
>>be based on the Document type. The CV type will have its own icon and
>>its representation will be slightly different than that of the Document
>>type.
>>-------------
>>
>>And I've done the PortalPollTutorial, where I can see how to add
>>properties but I'm not sure if that's necessary when all I really want
>>is for my new Document type to be just like CMFDocument but with 3
>>additional properties.


If you want to create your own type which has everything
CMFDefault.Document does, but adds an additional three properties,
the simplest tack would be:

  1. Create a ZClass, derived from CMFDefault.Document.

  2. Add a propertysheet to the ZClass with the properties you need.

  3. Customize the skins in your portal to use / update these properties.

I was able to do the above, and write it up, in about ten minutes.
I used the "Property Sheet Interface" object in the ZClass to generate
a form to edit the three properties, and then cut and pasted it into
my CMFSite's "custom" skins folder, and tweaked it to be a skin method,
rather than a ZMI method.  I probably could have generated the form
by hand in just a few minutes more.

WRT your second question:  these properties are "metadata" in a
sense;  if they are managed by the class itself, rather than by
the metadata tool, it is probably simple to think of them as
"content", even if you build indexes in the catalog to search on
them.

Tres.
-- 
===============================================================
Tres Seaver                                tseaver@zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com