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

Kyler Laird kyler-keyword-zope.c87f05@lairds.org
Thu, 2 Jan 2003 18:14:23 -0500


On Thu, Jan 02, 2003 at 06:04:48PM -0500, Brian Lloyd wrote:

> (Apologies if this has been answered already)

It hadn't - to me at least.  I appreciate you taking the time to
explain it so well.

> ZPublisher looks first for index_html, and will only use __call__ 
> if it doesn't find an index_html on the published object.

Ah!  That makes sense.  What doesn't make sense to me is that
PropertyFolder seems to work just fine for other people.  Why
would my PropertyFolder have index_html defined as something
that runs whatever index_html is in the object's context?

> 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__

That's pretty much what I've been doing.  I even submitted a
patch like that, but I was told that it broke in the
maintainer's system.  Something is not right.  (I've been
testing this on two systems and they both behave this way,
but I suspect PropertyFolder is in use widely.)

Unfortunately PropertyFolder *also* does a check like this. 
It says "If there is an object named [object_name] in the
context, run that.  Otherwise run index_html."  That exercises
the "maximum recursion depth" trap if I make index_html ==
__call__.

So...I overrode this behavior and made it just fail if it can
not find [object_name].  This works for now, but I'd prefer to
have the old behavior where it fails over to using the
context's index_html.  I suppose I could explicitly call the
context's index_html, but I'm not sure how.

> Hope this helps,

It does.  Thank you.

--kyler