[Zope-dev] getPersistentItemIDs not cooperating?

Steve Spicklemire steve@spvi.com
Wed, 23 May 2001 12:11:40 -0500


Hi Phil,

Yup.. I realized it when I could *list* all the ids, but not delete 
them. ;-) I'm wondering if it might be better to change the 
implementation of getPersistentItemIDs to return a plain list? This 
would also help avoid permission errors that folks run in to when trying 
to use it in dtml. I realize that listifying takes time, but you 
probably wouldn't call it if you had a very large number of items in the 
rack (you'd maybe query a catalog or something else.. )

-steve

On Wednesday, May 23, 2001, at 11:22 AM, Phillip J. Eby wrote:

> 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.