[Zope3-Users] How to make catalog working?

Jim Washington jwashin at vt.edu
Tue May 16 07:23:09 EDT 2006


Frank Burkhardt wrote:
> Hi,
>
> On Mon, May 15, 2006 at 11:16:09PM +0200, Florian Lindner wrote:
>   
>> Hello,
>> I've added some content objects of interface IFoo to my site.
>> Then I added a catalog to my site (and also a IntID utility). I registered 
>> both. To the catalog I've added a FieldIndex and a TextIndex, set the 
>> interface to IFoo and the fieldname to a field that IFoo has. I registered 
>> both indexes.
>>     
>
> The IntID utility has to be registered *before* all the objects you
> want to find. No object created before you had a registered IntID
> will ever be found.
>
> Have a look at
>
>  http://zope3.mpg.de/suchen ("Das Prinzip")
>
>   
You can get the IntIDs utility to register objects after they are created.

Something like the below will register and catalog a bunch of items:

def catalog_items(self):
        intids = zapi.getUtility(IIntIds,[name])
        catalog = zapi.getUtility(ICatalog,[name])
        for item in some_function_that_returns_the_items():
            catalog.index_doc(intids.register(item), item)

The most important part is the intids.register(item) statement.

-Jim Washington



More information about the Zope3-users mailing list