[ZPT] What to use for content?

Clemens Robbenhaar zpt@zope.org
Wed, 15 Jan 2003 14:22:08 +0100


Hi Max,


 > My problem is: What should I use as content objects? To start with the content 
 > itself will be HTML.
 > 
 > I've figured out how to use page templates for content, but that sort of defies 
 > the point. I also know I could use CMF or Plone, but both systems are quite 
 > complex and I want to learn more about Zope before going for a complete content 
 > management system.
 > 
 > Essentially I'd like things to work like this:
 > 
 > siteroot/index_html <- master template
 > siteroot/spam/eggs <- content object span in eggs folder
 > 

 You may want to take a look into the Zope Developers Guide, chapter
"Object Publishing" to understand what is going on.
(e.g.: http://www.zope.org/Documentation/Books/ZDG/current/ObjectPublishing.stx)

 A short summary: if You visit the URL to the content object,
Zope will look is the object is callable of has an 'index_html'
attribute. In Your case You most probably want the it to get the
'index_html' page template acqured from the Zope roof folder.

 This rules out many of the Zope standard objects, as the are either
callable or have their own 'index_html' attribute as a method of the
underlying python class, and thus do not acquire the 'index_html' form
the root. 

 The Kubes approach thus is not that stupid, as the above does not apply
to Zope folders; they acquire the 'index_html' from the root.


 If You are not afraid of writing Your own product on the file system
level, You could create an own product containing only one class, which
is basically a copy from the Zope 'File' class (which can be found in
the 'lib/python/OFS/Image.py', actually), but without the 'index_html' method.

This should acquire the 'index_html' from the Zope root
instead. 
 Actually I did not figure out if this works, as this need some
more copying around of the necessary management forms, etc.


 > When the user goes to http://mysite/spam/eggs I'd like to have the content 
 > object rendered through the index_html template. I'd also like to have some 
 > kind of possibility to devise a script which returns a sensible object when a 
 > folder is accessed.
 > 

 You can define a 'get_content' script in the Zope root,
which You call via 'tal:define="global content here/get_content"'
and which contains something like:

 if context.meta_type=='Folder'
   # return some default content here, e.g.
   return str(context.index_document)
 else:
   # hope we have the patched "file" object here
   # return the raw data of the file.
   return str(context)


It is not the thing I would recommend for a production site, but if You
want to explore how Zope works, this may be worth a try.

Maybe someone else has a simpler idea than that. 


Clemens