Andrew Altepeter wrote at 2003-2-3 13:10 -0600:
I am writing a product through the ZMI (which extends Folder) that contains products of the same type (basically a hierarchical system). I want to be able to delete an arbitrary item and all of it's sub-items. The method that does this is a recursive deleteMe() python script.
Here is the code that I am using:
def deleteMe(root=1): children = context.objectIds('NavigationMenu') if (len(children)): for child in children: context[child].deleteMe(root=0) context.manage_delObjects(children) if (root==1): context.aq_parent.manage_delObjects(context.id) The standard way to delete a subhierarchie is:
* you have a single call to "manage_delObjects(ids)". It deletes the subtrees rooted in "ids". * you customize "manage_beforeDelete" when you need special operations before the object is deleted.
So, to me this looks like your standard recursive function (well, sort of). However, when I get to the bottom of the tree, context.objectIds contains siblings, not children. I would expect that if there were no children, objectIds would return []. It depends on the base classes inherited by your product class.
In my view, it is a bug that "SimpleItem.Item" implements Object Manager methods (it is not such a thing!). You, on the other hand, would like that and apparently got a base class that does not define these methods. Dieter