[Zope] Re: Recursive Python Call in Zope
Christopher Baumbach
chrizmo_zopeList@gmx.de
Tue, 19 Nov 2002 14:46:59 +0100 (MET)
OK... The output is correctly given but now I have the problem, that not all
Folders are displayed... The script looks like this:
----------------------------------------------
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=obj=None, indent=0
##title=
if obj is None: obj=context
ind = " " * indent
folders = obj.objectValues('Folder')
if len(folders) <= 0: return printed
for folder in folders:
subfolders = folder.objectValues('Folder')
if len(subfolders) > 0:
print ind + "+" + folder.id
print script(subfolders[0], indent+1)
else:
print ind + "-" + folder.id
return printed
----------------------------------------------
I think there's a little silly failure...
C.
> 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.
> >
> >
>
>
> _______________________________________________
> 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 )
>
--
+++ GMX - Mail, Messaging & more http://www.gmx.net +++
NEU: Mit GMX ins Internet. Rund um die Uhr für 1 ct/ Min. surfen!