[Zope-CMF] Customizing content types

Sam Brauer sam at webslingerz.com
Tue Aug 26 15:53:44 EDT 2003


David Chandek-Stark wrote:
> I am engaged in a pilot project migrating a web site into Zope/CMF. This 
> may involve customizing some of the CMF content types (adding 
> properties) and/or creating new content types. I'm beyond the newbie 
> stage with Zope and the CMF, but can't see far enough down the road for 
> potential pitfalls. I'm concerned about upgrade problems with customized 
> CMF content and, in general, the sustainability of such a project. 
> Obviously it's a lot easier to simply make do with the CMF types, 
> perhaps bending the meaning of Dublin Core to accommodate the metadata 
> we want, but we'd prefer not to do that.
> 
> I've read the CMF Dogbowl how-to on Scriptable Type Information objects 
> and the ZopeLABS article on adding custom properties to CMF default 
> content. How does one determine whether to add a custom property to a 
> CMF type or to create a new scriptable type altogether?
> 
> Thanks for any help, advice, thoughts.
> David
> 


If your types are fairly similar to the default types, then using 
scriptable types is an easy approach.
However, creating your own content types as Python products will give 
you the most flexibility and control (not to mention that you'll learn a 
lot of valuable lessons about Zope along the way).

I would suggest using something like 
http://dev.zope.org/Members/1000asa/CMFGenericProduct
as a starting point.

(http://www.zope.org/Members/digitalis/basic_cmf_product/how_to is also 
good, but assumes Plone instead of plain CMF.  Can be a good source for 
reference though.)

 From there, try converting the CMFGeneric product to use ZPT instead of 
DTML for the skin.

Then you could try to create your own product.

Eventually you may want to create your own base content type that deals 
with a lot of the tedious details of registering with the types and skin 
tools for you.  You can then subclass this base type pretty quickly 
whenever you need a new content type.  (That's the idea behind 
Digitalis' Basic CMF product mention above.)

As your types evolve over time, you can give your classes a __setstate__ 
method to add or remove attributes whenever an old instance is retrieved 
from the ZODB.

Studying the source in CMFDefault and CMFCore will answer a lot of 
"howto" questions for you.  While it's not CMF-specific, I think The 
Zope Bible is the best English-language printed book currently available 
on developing Python-based products.  Unfortunately, it also uses DTML 
for the example product templates (thought it does have a pretty good 
chapter on ZPT).  Finally, a lot can be learned by searching the CMF 
mailing list archives.  Just be wary of outdated information.

-- 
Sam Brauer
Systems Programmer
sam at webslingerZ.com




More information about the Zope-CMF mailing list