[Zope] ZCatalog PathIndex Query
Alec Mitchell
apm13 at columbia.edu
Mon Mar 14 19:20:40 EST 2005
On Monday 14 March 2005 04:09 pm, Nathan Colgate Clark wrote:
> In an 'advanced search' interface i would like to provide the ability
> to search using the path index of my catalog (index id: 'p', catalog
> id: 'Catalog').
>
> A sample of my catalog:
> /site_root/publications
> /site_root/publications/newsletter
> /site_root/publications/newsletter/edition01/articleA
> /site_root/publications/newsletter/edition01/articleB
> /site_root/publications/magazine
> /site_root/publications/magazine/fall2003/articleC
> /site_root/publications/magazine/fall2003/articleD
> /site_root/publications/magazine/winter2003/articleE
> /site_root/publications/magazine/spring2003/articleF
>
> So that if the user were to type "magazine" into the field they would
> get the last 5 objects in my catalog.
>
> however, this does not work right now. currently i have to type
> "/site_root/publications/magazine" into the field. this is becuase
> the default level for pathIndex searches is 0 (line 154 of
> PathIndex.py). to change this I must pass the argument as a tuple
> (query,level) with the level set to -1. My question is this: how do
> I do that using the get method of a form? how do I pass the
> (query,level) tuple from the form in the URL?
>
> I have tried this:
> http://www.mysite.com/search?p=magazine&p=-1
>
> which gives me a p variable of:
> ['magazine','-1']
> but still does not give me any results.
Try:
http://www.mysite.com/search?path.query:record=magazine&path.level:record:int=-1
Using a hidden field in the form with the name set to "path.level:record:int"
and the value set to -1 should do it. This marshalls a path variable as
something like a dict (a record object), and stores the integer '-1' as the
value for the key 'level'.
Alec Mitchell
More information about the Zope
mailing list