I've never done this but it should be fine. The only problem with mutation and iteration is if you continue to iterate over the mutated list: for item in folder.objectValues(): item.do_something() if blah: folder.manage_delObjects(item.getId()) This pattern can result in items getting skipped in some languages/environments. But I've never encountered a system that cares what you do once you have decided to stop iterating.
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of John Hunter Sent: Monday, October 21, 2002 10:17 AM To: Zope Users Subject: [Zope] deleting while iterating over ObjectManager
Is it safe to delete instances while iterating over the contents of an ObjectManager instance, as in:
for item in folder.objectValues(): if some_condition: folder.manage_delObjects(item.getId()) break do_something(item)
Thanks, John Hunter
_______________________________________________ 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 )