[Zope] How to restrict search path in portal_catalog(path='')

Dieter Maurer dieter@handshake.de
Fri, 4 Jul 2003 22:41:27 +0200


saravanan  annamalai wrote at 2003-7-4 14:51 -0000:
 >    I have the following requirement.
 > 
 > I just want to get the news items present in root folder only... 
 > /root
 > not those in /root/Member's folders...
 > 
 > using     container.portal_catalog(meta_type='News Item',path=' 
 > ')
 > 
 >    I tried to use path argument as /root... But it doesnt work....  

Path indexes are unable to do that.

They have the property:

  When an object with path "somepath/id" is a hit than any 
  object with path "somepath/anotherpath" is also a hit.

  You are therefore unable to restrict the depth of the hits
  (to the root folder in your case).

In your case, you may directly use "folder.ContentValues(['News'])"
(or similar; I am not sure about spelling).


An alternative would be to enhance PathIndex with a "depth" parameter
which allows to restrict the depth of hits.


Dieter