[Zope] Strange For loop with ZCatalog
Casey Duncan
casey at zope.com
Mon Feb 9 11:38:23 EST 2004
On Mon, 09 Feb 2004 15:07:42 +0100
Pascal Samuzeau <samuzeau at oreka.com> wrote:
> Hi,
>
> For some tests I have done :
>
> - Create about 5000 folders under the Root Zope Site
> - Inside those folders, I have created about 30 000 objects ( as
> document, just an id, title and a Type).
> - I've catalogued all inside a catalog named TheCatalog
>
> I have written just this function, in intend to test my CPU ( that why
> I've written it like this):
>
> allobject = context.TheCatalog.searchResults(Type='TypeTest')
> l=len(allobject)
> i = 0
> #for i in range(len(allobject)):
> for object in allobject:
> #path = allobject[i].getPath()
> #course = allobject[i][0]
> path = allobject.getPath()
> course = allobject[0]
The above three lines don't make sense to me. I have no idea with
allobject.getPath() would return (by all indications it should be an
error unless it acquires something named getPath). Also, allobject[0] is
always the same thing, the first catalog result. allobject[i][0] doesn't
make sense, the first item of the ith catalog result? I don't know what
you would get from that (I'm surprised it's not an error).
> thepath = string.split(path,'/')
> lepath = string.join(thepath[:-1],'/')
> lieu=context.restrictedTraverse(lepath)
> lieu.manage_delObjects(course)
> i+=1
> return "Len: %s and Number parsed: %s" %(i,l)
What happens if you just do:
i = 0
for obj in allobject:
i += 1
return i
?
-Casey
More information about the Zope
mailing list