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

Brian Lloyd brian@zope.com
Thu, 2 Jan 2003 18:04:48 -0500


> 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__(...):
    ...

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


Hope this helps,

Brian Lloyd        brian@zope.com
V.P. Engineering   540.361.1716              
Zope Corporation   http://www.zope.com