[Zope-dev] automatically doing a Catalog search as part of ob ject traversal...

Toby Dickenson tdickenson@geminidataloggers.com
Tue, 30 Nov 1999 12:19:27 -0000


> -----Original Message-----
> From: Anthony Baxter [mailto:anthony@interlink.com.au]
> Sent: 30 November 1999 06:19
> To: zope-dev@zope.org
> Subject: [Zope-dev] automatically doing a Catalog search as part of
> object traversal...
> 
> 
> Say I have a catalog HelpCatalog, with a bunch of documents that have
> unique IDs. I want to be able to do something like
> HelpCatalog/by-id/SomeUniqueID
> and have it return the document SomeUniqueID.

I looked at doing something like this just after the release of 2.0, but ran
across a problem. Catalog.getobject calls HTTPRequest.resolve_url, which
starts its resolving process from REQUEST.PARENTS[0]. 

However REQUEST.PARENTS is not available until after the original url
traversal is complete, therefore it is not possible to use
ZCatalog.getobject (or resolve_url) as part of url traversal.

(actually, REQUEST.PARENTS is available, however its elements are in a
reversed order).

I could get around this problem by storing the ids, and performing the
search  on demand. This worked for me since I wanted the searched-for
objects to be parameters to the request. I will not quite work for you since
you want the request to be handled by the searched-for object.

> Do Catalogs support any sort of Direct Traversal like this? 
> Or am I going
> to have to do it myself with a mixin class?

oh yes.