[Zope] Re: Recursive Python Call in Zope

peter sabaini sabaini@inode.at
Tue, 19 Nov 2002 14:27:26 +0100


maybe this is what you want? you also need to print the output of the 
recursive call

## Script (Python) "test_py"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=obj=None, indent=0
##title=
##
from Products.PythonScripts.standard import html_quote

request = context.REQUEST
RESPONSE =  request.RESPONSE

if obj is None: obj=context

folders = obj.objectValues('Folder')

if len(folders) < 1: return printed

for folder in folders:
     ind = " " * indent
     print ind + folder.id
     print script(folder, indent+1)

return printed

[snip]

this would
hth,
peter.


Christopher Baumbach wrote:
>>Can you post your script, so we can see what's wrong with it?
>>
> 
> 
> OK, here's my Script:
> 
> ------------------------
> #Args: obj=None, indent=0 (for the view)
> 
> from Products.PythonScripts.standard import html_quote
> request = context.REQUEST
> RESPONSE =  request.RESPONSE
> 
> if obj is None:
>     obj=context
> 
> folders = obj.objectValues('Folder')
> 
> if len(folders) > 0:
>    for i in range(len(folders)):
>       folder = folders[i]
>       ind = " " * indent
>        subfolders = folder.objectValues('Folder')
>        print ind + folder.id
>        if len(subfolders) > 0:
>          script(subfolders[i], indent+1)
> 
> return printed
> ------------------------
> 
> ...it's not very complex - maybe I have to do more Python-practice ;-)
> 
> thanks for help,
> 
> C.
> 
>