[Zope] with a __call__

Chris Withers chrisw@nipltd.com
Fri, 27 Oct 2000 16:26:45 +0100


Max Møller Rasmussen wrote:
> I want to write my "index_html" method so that it returns a rendered version
> of "list.dtml" corresponding to the selected view, by the name of the folder
> holding  the selected view.
> 
> something like this (which doesn't work):
> 
> def index_html():
>     return HTMLFile('views/' + self.selView+ 'list')

You actually want to write a __call__ method (something) like this:

    def __call__(self, REQUEST=None, **kw):
        """"""
	return apply(HTMLFile('views/' + self.selView+
'list'),(self,REQUEST),kw)


    index_html=None

...this last bit is needed so index_html isn't acquired from an object
above.

cheers,

Chris