[Zope-dev] Calling Catalog from python script

Casey Duncan cduncan@kaivo.com
Wed, 14 Feb 2001 16:44:57 -0700


"R. David Murray" wrote:
> 
> I'll probably figure this out as soon as I post like last time, but I've
> been staring at it and can't see my mistake.  The following code returns
> a list of None's:
> 
> objs = []
> for catent in container.Catalog(context.REQUEST):
>   objs.append(container.Catalog.getobject(catent.data_record_id_))
> return objs
> 
> I've checked, and catent is a mybrains instance and catent.data_record_id_
> has an increasing number as its value.  So why doesn't this work?
> 
> Also, and this is a better reason for posting this to zope-dev than
> asking for help is <grin>: why can't I say
> 
>   catent.getobject()
> 
> That would seem to be a lot more OOish.
> 
> This is under Zope-2.3.0, by the way.
> 
> --RDM
> 
That code looks pretty good to me. Did you try updating the Catalog?
Also, what happens if just append catent. Do you get something other
than None then? I would assume so, but it might help to see exactly what
the meta data is to identify the objects it "should" return.

I agree that getobject should be a method of the result item, although
implementing it might be a bit tricky to do. I looked into that a while
back. Perhaps I should take another look at that...

-- 
| Casey Duncan
| Kaivo, Inc.
| cduncan@kaivo.com
`------------------>