[Zope] DTML-IN only over special documents??

Thomas B. Passin tpassin@mitretek.org
Tue, 19 Mar 2002 13:54:55 -0500


[Phil Harris]

> <dtml-in "objectValues(['some meta type'])">
>   <dtml-if "_.string.find(_['sequence-item'].getId(),'mydoc') ==0">
>   do something here
>   </dtml-if>
> </dtml-in>
>
> or preferably do it in a python script:
>
> #script called mydoc_filter
> import string
> l=context.objectValues(['some_meta_type'])
> retval=[]
> for a in l:
>   if string.find(a.getId(),'mydoc'):
>     retval.append(a)
> return a
>
Remember that string.find returns -1, not 0, if it can't find the substring,
so this test won't work if the value starts with the search string.  The
test needs to be

if string.find(a.getId(),'mydoc')>-1:

Cheers,

Tom P