[ Andrew Altepeter]
Are there any tricks/quirks in recursive python scripts I should know about? It appears that one section of this list isn't being deleted, so when the script is called again (i.e. starting the recursive algorithm again), the list that is initially create is the list from the previous call.
Try adding a "depth" parameter to track the recursion level. For the first iteration, have the method print or otherwise log the list, so you can see what it starts out as.
I'll put the code here so hopefully someone can point out an (obvious) bug :-)
Oh, the list that I'm building is of the form: [[object, [objects children]]] And, it's necessary to have the second outer list.
... #create a new child_q new_queue = [[context, queue]]
if (context.is_root != 1): return context.aq_parent.getRootedMenuList(new_queue) else: return new_queue
It looks to me like everything should be released by the time the thing returns from recursion. I would be the most concerned about "queue" and "new_queue" because they seem to have the most potential for keeping references hanging around - who knows what references Zope may construct once the thing returns? So the one thing I would try first is this -
if (context.is_root != 1): return context.aq_parent.getRootedMenuList(new_queue) new_queue = None #just in case ... else: return new_queue
Where does "is_root" come from? BTW, you do not need the parens around the condition expressions in the if statements. Cheers, Tom P