RE: [Zope] Why is index_html() called instead of __call__()?
Brian wrote:
ZPublisher looks first for index_html, and will only use __call__ if it doesn't find an index_html on the published object.
Looking at ZPublisher/BaseRequest.py, I'm starting to understand.
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.
Further, this is the *only* way to do it. As I've noticed recently, any attempts to delete index_html in the root folder will result in recreation at the next upgrade (for Debian at least). Because there will always be an index_html in the heirarchy, there is no way to affect behavior by defining __call__. Because there is no hook before index_html, is is impossible to (cleanly) make an object that renders itself sometimes, and allows index_html to do it at other times.
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__
This would result in never being able to call the index_html in the ZODB. --kyler
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__
This would result in never being able to call the index_html in the ZODB.
--kyler
Sure you could :) You just have to do it explicitly: def __call__(self, REQUEST, ...): if i_want_to_call_acquired_index_html: # acquire it from our parent, to avoid getting our own! index_html = getattr(self.aq_parent, 'index_html', None) if index_html is not None: return index_html(self, REQUEST) ... index_html = __call__ Brian Lloyd brian@zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com
On Mon, Jan 06, 2003 at 11:18:19AM -0500, Brian Lloyd wrote:
# alias to be sure we always control our rendering index_html = __call__
This would result in never being able to call the index_html in the ZODB.
Sure you could :) You just have to do it explicitly:
I should have been more explicit. I can never call the index_html in that PropertyFolder. In fact, I can't even create it. (Yes, I tried this approach for awhile.) My solution is to use "index" instead of "index_html" in the ZODB. ("index_html" always struck me as a really dumb name for something that might not even generate HTML. Regardless, having a content type in a URL is embarrassing.) I already stopped using index_html in most of my systems long ago, so this shouldn't be a big deal unless users import things from elsewhere. Thank you for the suggestion. --kyler
participants (2)
-
Brian Lloyd -
Kyler Laird