[Zope] ZopeBook - URL to SQL
Dieter Maurer
dieter@handshake.de
Fri, 24 Nov 2000 21:47:33 +0100 (CET)
Chris Gray writes:
> The Zope book discusses calling a ZSQL Method via a URL, saying that a
> request for a URL like:
>
> http://localhost:8080/zsql_method/parameter/value
>
> "will return a result object", but what I get is the index_html document
> at the root, although I do get a rendered record with:
The ZPublisher works as follows:
It traverses the ZODB guided by the components in your URL.
It it arrives at the URL's end, it checks whether the
reached object is callable (this is the case for all
kinds of methods and documents). If it is, the object
is called.
If it is not, ZPublisher checks, whether the object
has (or can acquire) a method "index_html"
(this usually is the case). It then calls this method.
In your case:
ZPublisher will reach the result object (as the Zope book
describes). Unless you have wrapped this object
into a custom class (aka brain, see "Advanced" tab),
this is a "Record" object.
A "Record" object is not callable.
"index_html" is looked for, found in a folder above and
rendered.
That's what you see.
What can you do?
Wrap you results into a custom brain that either
defines a "__call__" (that would need to be a
Python defined class) or an "index_html" (this
may be a non-persistent ZClass).
Dieter