[Zope] searching keywords with AND

marc lindahl marc@bowery.com
Sun, 20 May 2001 19:45:32 -0400


> From: Chris Withers <chrisw@nipltd.com>
>
> I don't think you're testing thsi correctly. This is one of the things I'm
> really looking forward to in Zope 2.4
>

Came up with something to fit my situation:

  <dtml-in "portal_catalog.searchResults( {'meta_type' : 'Portal Audio'
                                          ,'Subject': 's1'}
                                        , sort_on='Date'
                                        , sort_order='reverse'
                                        , review_state='published'
                                        )" size="10">
  <dtml-if "list1inlist2(['s2','s3','s4'],Subject)">
 <blah blah, put the stuff to display each list element here>


where list1inlist2.pys looks like:

#returns true if ALL elements of list1 are in list2

for l1 in list1:
   if l1 not in list2:
      return 0
return 1

So, the first search gives an overbroad list, but at least not the entire
catalog...  then I just chuck anything in there that doesn't meet the more
restricted requirements.