[Zope] Traversing a Root Level Folder's Hierarchy

J. Cameron Cooper jccooper@jcameroncooper.com
Tue, 11 Feb 2003 12:41:08 -0600


>
>
>Hello. Does anyone know how to traverse a folder
>hierarchy in Zope? More specifically, I would like to
>add a property to all folder objects that lie beneath
>a root level folder-the only way to do this is to
>traverse the folder hierarchy that lies beneath this
>root level folder. Using the dtml-tree command allows
>me to go only one layer deep at a time and the same
>applies for the dtml-in command. Any input would be
>greatly appreciated. Thanks.
>
Forget DTML. It's presentation. This is logic.

Make yourself a recursive Python Script:

 - you pass in a folder/folder id
 - it adds your attribute to that folder
 - it looks up all the (folderish) children of that folder
 - it calls itself on those children, if any

And suddenly, you've got yourself a tree walker.

All of the steps above can be found in the online help system's API 
reference, but let us know if you stumble on anything.

Note: I didn't test this (else I'd have given you the code!) but there's 
no reason it shouldn't work.

              --jcc
      (a clean separation)