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

Casey Duncan casey@zope.com
Tue, 19 Mar 2002 10:48:38 -0700


dtml in does not have a built in facility to filter this way, but you 
can write a short python script that returns a list of objects named a 
certain way:

docs = []
for id in context.objectIds('DTML Document'):
     if id.startswith('mydoc'):
         docs.append(context[id])
return docs

If you call this getDocs, you could use it in dtml like so:

<dtml-in expr="Folder.getDocs()">
...
</dtml-in>

Just put getDocs somewhere where Folder can acquire it. Or if you want 
to squirrel it away somewhere (like in a "scripts" folder), add an 
parameter to the script so you can pass it the folder to look in. You 
could also add parameters for the meta-type and name to look for to make 
it more generic.

BTW: The above code assumes Python 2.0 or better.

hth,
Casey

Breitenreicher, Marc wrote:
> Hi,
> I've got a question concerning dtml-in.
> 
> I know that it is possible to loop only over DTML Documents in a folder
> containing objects of different type.
> But is it possible to loop only over documents, that id's e.g. start with
> 'mydoc' ???
> 
> Example-folder with the objects:
> mydoc1 
> mydoc35 
> picture567 
> picture33
> mydoc98
> 
> So dtml-in shall only loop over 'mydoc1', 'mydoc35', 'mydoc98'
> 
> How can I do that?
> 
> TIA
> 
> Marc
> 
> 
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
> 
>