Guillaume Michon
2004-07-28 09:50:58 UTC
Hi all,
The following code does not work as expected :
for o in container.contentValues():
container._delObject(o.getId())
The reason is that python does not calculate the expression
"container.contentValues()" only one time, but at each passage through the
for. So modifying content of container changes the result of the expression.
Then the behavior is undeterminable.
The secured way to do is to build a list of ids to delete, then delete them :
to_delete = []
for o in container.contentValues():
to_delete.append(o.getId())
container.deleteContent(to_delete)
Regards,
Guillaume
The following code does not work as expected :
for o in container.contentValues():
container._delObject(o.getId())
The reason is that python does not calculate the expression
"container.contentValues()" only one time, but at each passage through the
for. So modifying content of container changes the result of the expression.
Then the behavior is undeterminable.
The secured way to do is to build a list of ids to delete, then delete them :
to_delete = []
for o in container.contentValues():
to_delete.append(o.getId())
container.deleteContent(to_delete)
Regards,
Guillaume