[Zope] recursive iteration in External Method

Tino Wildenhain tino@wildenhain.de
Mon, 25 Nov 2002 20:56:53 +0100


Hi Elena,

it does not look like your recursion does not work
properly but perhaps you are activating too many
objects and so run out of memory and get into timeout.
May be you should try it with a much smaller subtree
and if it works try to use sub-transactions (like ZCatalog
does) to avoid intensive memory allocation.

Regards
Tino

--On Montag, 25. November 2002 19:51 +0100 Elena Schulz 
<elena.schulz@gmx.net> wrote:

> Hi,
>
> I'have got a problem with recursive iteration through all subfolders in an
> External Method. My pc gets out of system-resources doing the following
> iteration. Does anybody see a problem why this don't stop properly? I have
> no clue ...
>
> -- many thanks for your replies, Elena
>
> def sendObject(self, object, objPath):
>     # do something with no effect on iteration
>     return
>
> def iterateObjects(self, object, objectPath, basePathLevel, destPath):
>     if object.meta_type == 'Folder':
>         objectPath = destPath + '/' +
> '/'.join(object.absolute_url().split('/')[basePathLevel-1:])
>         for child in object.objectValues():
>             if not (hasattr(child, 'noUpload') and child.noUpload):
>               sendObject(self, child, objectPath)
>               iterateObjects(self, child, objectPath, basePathLevel,
> destPath)
>     return
>
> def uploadObjects(self, ids, destPath, addSubfolder):
>     for objectId in ids:
>         object = getattr(self, objectId)
>         sendObject(self, object, destPath)
>         objectPath = destPath + '/' + objectId
>         if addSubfolder:
>             basePathLevel = len(object.absolute_url().split('/'))
>             iterateObjects(self, object, objectPath, basePathLevel,
> destPath)
>     return
>
>
> _______________________________________________
> 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 )