[Zope] Re: Why is index_html() called instead of __call__()?

Maik Jablonski maik.jablonski@uni-bielefeld.de
Fri, 03 Jan 2003 00:48:05 +0100


Brian Lloyd wrote:
>>I've been trying to use PropertyFolder for awhile now.  Almost
>>all of my projects depend heavily on functionality that it
>>would make *much* cleaner.
>>
>>I'm running a fairly standard Debian distribution of Zope, but
>>I have to modify PropertyFolder to define index_html() instead
>>of __call__(), otherwise the "object_type" renderer is ignored.
>>I'm not sure PropertyFolder is to blame.
>>
>>Should an object's __call__() method be used to render it?  Any
>>ideas why index_html() might be used instead?  Where could I go
>>to track down the misbehavior?  I'd like to fix this so I can
>>move on to some enhancements.
> 
> 
> (Apologies if this has been answered already)
> 
> ZPublisher looks first for index_html, and will only use __call__ 
> if it doesn't find an index_html on the published object. Note 
> that the index_html may be acquired from a containing object, so 
> an object that always wants to control its own rendering should 
> define its own index_html to prevent that. It sounds like the 
> PropertyFolder implementation might want to do something like:
> 
> class PropertyFolder(...):
>   def __call__(...):
>     ...

That's what it already does...:) And it hooks into ZOPE's 
__browser_default__ to determine which template for rendering should be 
used (user-defined via an attribute or existing default index_html).

>   # alias to be sure we always control our rendering
>   index_html = __call__

If you set index_html this way, you can't add a index_html into a 
PropertyFolder anymore. That's the reason why I use __browser_default__ 
and don't want to set index_html. With Zope2.6 it works pretty well...

> Hope this helps,

me too..:)

Cheers, maik