Chris Withers wrote:
> Yup,
> This looks good, as did your earlier post. However, it raises a question
> :(
> Something like a ZCatalog or a Squishdot Site (which I have a passing
> interest in ;-) are both folderish. However, their __call__ method does
> something quite different: it returns the results of searching the catalog
> (I think this is the ZSearchable Interface, correct me if I'm wrong ;-)
> I guess what's bothering me is why __call__ has this dual role and how the
> rendering process manages to correctly render index_html even on a
> Squishdot object which is actually callable?

I just looked over the source to ZCatalog. I'm pretty sure that __call__
has nothing to do with any index_html you might add to a catalog.

The __call__ method is what gets invoked when you call the method,
either through the magic of <dtml-var Catalog> or with <dtml-var
"Catalog(client, namespace, args*)">.

If Catalog has an index_html, or acquires one, then that is what gets
rendered when you go to the URL http://mysite.tld/foo/Catalog --
actually, it seems that the effective URL is
http://mysite.tld/foo/Catalog/index_html. Therefore, if you don't have
an index_html, it gets acquired.

This behaviour is set in lib/python/ZPublisher/, method
traverse(), line 257. (I'm using 2.2 final).

        # Set the default method
        if method=='GET' or method=='POST':
        else: baseflag=1

and later on, at line 300.

                elif (method and hasattr(object,method)
                      and entry_name != method
                      and getattr(object, method) is not None):
                    entry_name = method

So, if you're getting or posting, you effectively get "index_html"
appended to your URL.

This way of doing things allows individual classes to define protocol
handlers for other protocols they wish to support -- such as the PUT()
method in Thus, index_html() is the protocol handler for

This mechanism is pretty much separate from the __call__ mechanism.

In conclusion, I can't see any disadvantage to making Folder callable as
I suggested in a previous message. It doesn't appear to break anything

> Hmm... I guess the implication of this is that a normal folder will never
> render itself to avoid confusion over the ZSearch interface and so if I
> want this behaviour I'll have to roll-my-own folder which inherits from
> ZCallable.

I'm not sure your paragraph above makes sense in light of what I've said

> PS: Shane: what's the difference between ZCallable and the ZRenderable
> base class that Maik Roeder mentioned on [EMAIL PROTECTED] a few days back?

IIRC, ZRenderable lets you choose what method you want __call__ to
forward to, whereas ZCallable always chooses the method index_html, if
it exists.

Steve Alexander
Software Engineer
Cat-Box limited

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to