[Zope-dev] getPersistentItemIDs not cooperating?
Steve Spicklemire
steve@spvi.com
Wed, 23 May 2001 11:58:38 -0500
Well.. it turned out to be more subtle.
It goes back to the old problem that getPersistentItemIDs doesn't return
a real list, but rather a BTreeItems object. When you call manage_delete
on *one* item, it affects the BTreesItems object you are iterating over!
This works:
## Script (Python) "deleteAllTracks"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
trackMaster=context.Tracks
import string
iList=[]
for id in trackMaster.defaultRack.getPersistentItemIDs():
iList.append(id)
dList=[]
for id in iList:
theItem=trackMaster.getItem(id)
theItem.manage_delete()
dList.append(id)
return ("OK! deleted %i elements" % len(iList)) + string.join(iList,',')
On Wednesday, May 23, 2001, at 10:59 AM, Steve Alexander wrote:
> Steve Spicklemire wrote:
>
>> Has anyone seen anything like this?
>> <snip>
>> 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.
>
>
> Yes, I've seen this. It's on my list of things to look into when I've
> got a certain large project out of the way :-/
>
>> Thoughts?
>
>
>
> Well, getPersistentItemIDs() just returns the result of calling keys()
> on the Rack's BTree.
>
>
> I guess it is a problem with the BTree code.
>
> I doubt it'll be fixed though. Instead, we should update Rack to use
> the new BTrees module.
>
> --
> Steve Alexander
> Software Engineer
> Cat-Box limited
>
>
>
> _______________________________________________
> Zope-Dev maillist - Zope-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zope-dev
> ** No cross posts or HTML encoding! **
> (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope )