[Zope-dev] getPersistentItemIDs not cooperating?

Phillip J. Eby pje@telecommunity.com
Wed, 23 May 2001 12:22:59 -0400


At 05:48 PM 5/23/01 +0200, Christian Scholz wrote:
>Hi!
>
> > It works.. partially. For some reason it looks like getPersistentItemIDs
> > does not always return a *complete* list. I need to run this method
> > several times to completely exhaust the Rack's storage. Thoughts? The
> > only way I ever create Track objects is via a different method that is
> > only accessed once (a long time ago!)
>
>Well, I experiences something similar when changing a Racks storage
>from persistent to non-persistent. The included objects are marked
>as orphaned then and should be deleted with the Clear-Button. This
>also works, but only the half of them gets deleted every time I click
>on that button.. So I also have to press it several times.. Sounds like
>the same problem..

I just thought of how this happens...  if you delete an object from the 
Rack, it's being removed from the virtual list of keys your loop is 
traversing.  So as you iterate from 0..n, and you delete  items from the 
rack, they are removed from the keys list too, the list shortens, and every 
other item in the list is skipped!  This is why you get half the list every 
time.

The fix would probably be:

foo = getPersisentItemIDs()

while foo:
     foo[0].manage_delete()

I should probably do this in ZPatterns too.  I'm working on upgrading it 
for 2.3.2 right now anyway.