[Zope] folders recursively

Ivan Cornell ivan.cornell@framestore.co.uk
Thu, 29 Mar 2001 15:22:07 +0100


Petr Knapek wrote:

> Hi Zopists,
>
> I would like to call some DTML method on all Folders in my ZODB.  I
> think the best way should be recursion but I do not know how to do
> it in DTML.
>
> Please, can you help me, or do you know any HOW-TO etc? I have found
> nothing.

I have a reindex method that does this: (simplified)

<dtml-in "objectItems(['my zclass types - could be Folders for you')">
Indexing &dtml-id; ...
  <dtml-with sequence-item>
    <dtml-call "this().reindex_object()">     <<<< Whatever you want done
on each item
 ... Done: <dtml-var "this().absolute_url()"></br>
  </dtml-with>
</dtml-in>

<dtml-in "objectItems(['Folder'])">
  <dtml-with sequence-item>
<b>Entering <dtml-var id></b></br>
    <dtml-var reindex>                        <<<< The recursive call!
  </dtml-with>
</dtml-in>


HTH

Ivan