[Zope-CMF] Searching sub-paths

Karim Yaici karimy@nipltd.com
Thu, 28 Jun 2001 11:01:07 +0100


Hi there,

>----- Original Message -----
>From: "Bjorn Stabell" <bjorn@exoweb.net>
>Hi folks,
>
>Is there a way using the ZCatalog (portal_catalog) to specify that you
>only want (or don't want) objects residing in a certain path?

This is not the nicest way to do it, but this does the job.

*Warning* Untested code:
<dtml-in portal_catalog.searchResults(criteria)>
  <dtml-if "getPath()=='your/path/'">
   do this
  <dtml-else>
   do that
  </dtml-if>
</dtml-in>

You can also call a python script which does the filtering:

PythonScript: filter_results
Parameter List: brains

import string
for brain in brains:
  path = brain.getPath()
  if string.split(path,'/')[-2]!= 'your_folder': # to remove those you don't
want
    continue
  # Otherwise do stuff with it and return something

Then you can call it from a dtml method:

 <dtml-let brains="portal_catalog.searchResults(criteria)">
  <dtml-return "filter_results(brains)">
</dtml-let>

I can't think of way to avoid checking all the brains before filtering (b/c
the path is not stored in the portal_catelog).

Cheers,
Karim
_______________________________________________
Zope-CMF maillist  -  Zope-CMF@zope.org
http://lists.zope.org/mailman/listinfo/zope-cmf

See http://www.zope.org/Products/PTK/Tracker for bug reports and feature
requests