[Zope] - can't __call__ objects?

Andreas Kostyrka andreas@ag.or.at
Fri, 18 Dec 1998 22:51:48 +0100 (CET)


On Fri, 18 Dec 1998, Amos Latteier wrote:

> Bobo^H^H^H^HZPublisher call's an object's 'index_html' method, if no method
> is specified.
> 
> So if you want your __call__ method to be considered the default published
> method here's how to do it:
> 
> class CallMe:
>   "defines __call__ as the default publishing method"
> 
>   def __call__(self):
>     "call the object"
>     ...
> 
>   index_html=__call__
That's not really desirable many times, as one'd like the DocumentTemplate
behaviour of calling an object with self==containing folder.
Additionally index_html is called with the wrong idea of location:
..../test.gif
is interpreted as the URL
..../test.gif/index_html

For this to work, one has to add the parameter/default values to the
object to emulate a real callable object. It seems probable that you can
even have any parameter combination, including RESPONSE, which would allow
images to be pseudo methods too :)
(Not that it matters for images, but anything that is returning in fact
 text as SQL methods, HTML file methods, LaTeX methods, etc. should be
 able to be an method. If one needs an property context around the method,
 one can still use a directory with the object in it as index.* stuck in.)

Andreas
-- 
Win95: n., A huge annoying boot virus that causes random spontaneous system
     crashes, usually just before saving a massive project.  Easily cured by
     UNIX.  See also MS-DOS, IBM-DOS, DR-DOS, Win 3.x, Win98.