[Zope] - can't __call__ objects?

Jim Fulton jim.fulton@digicool.com
Mon, 21 Dec 1998 12:46:56 -0500


Andreas Kostyrka wrote:
> 
> 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

Right.  In particular the base href gets set to .../test.gif, 
not .../

> 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 :)

Exactly.  ZPublisher won't call something unless it smells like a function
(or method).  In particular, it can't marshal parameters unless it
hase some function meta-data telling it how.  Now, I suppose that if
an object has a __call__ method, it could get the meta-data from that.
Hm.  I wonder why it doesn't do that.  I must have had a good
reason. ;) Maybe this should change.

Jim

--
Jim Fulton           mailto:jim@digicool.com
Technical Director   (888) 344-4332              Python Powered!
Digital Creations    http://www.digicool.com     http://www.python.org

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.