[Zope] zpt, metal and missing content objects (bit long)

Jochen Haeberle listen@midras.de
Thu, 12 Sep 2002 17:46:19 +0200


At 15:23 Uhr +0100 12.09.2002, Tim Hicks wrote:
>So, with that little issue overcome, I guess the only thing I'm left
>wondering is why my content objects need to contain any explicit use of zpt
>*within their source* (as opposed to as a property on the object).  Using
>only standard zope objects, the only ways I can see of overcoming this
>require nasty url mangling that locks me into a specific site system (due to
>embedded links).  By this I mean, if I want to have a zpt called as a method
>of my object when it's rendered, I could do one of:
>
>/render?id=content_object
>/content_object/view
>
>where 'render' is some sort of script that does something like
>standard_template.__of__(content_object) and where view is an alias to
>'standard_template'.

No, you don't need such things. All objects in Zope, that need this, 
have their own view method... folderish objects on the other hand, 
look for an index_html for default. This way you can achieve the 
rendering of an object (a folder is an object, too) using the given 
template.

This idea is abit difficult to grap at first and is quite different 
from what other AppServers do!

Did you have a look at the Zope Book 
(http://www.zope.org/Documentation/Books/ZopeBook/current), 
especially the part on acquisition and ZPT already? You need to graps 
the idea of acquisition, first...



You would _not_ use a zpt as a content object! A ZPT is a template 
for viewing content. It holds placeholders where your content is put 
in. Your content would be stored in specialised objects that fit your 
needs for that. those objects hold the content usually in properties.

You are right, there is no Basic-Zope object besides fodler that work 
this way :-( But you can experiment further with more objects.

I guess the best way for you would be to create a ZClass. In it you 
can define the properties that make up your content and you can 
define the view- and edit-methods needed, even based on ZPT, but you 
probably need to learn some more things first ;-)

Regards
Jochen