[Zope] recursive iteration in External Method

Elena Schulz elena.schulz@gmx.net
Mon, 25 Nov 2002 19:51:50 +0100


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