[Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

Martijn Faassen faassen at infrae.com
Wed Nov 23 06:49:12 EST 2005

Johan Carlsson wrote:
> Anyone had any success with ZCatalog in Zope 3?

Sure. I'm not sure what the problem is but I see you get a lot of 
replies. We (Infrae) certainly got it working without having to patch 

Um, the setup code we use it something like:

def _registerUtility(context, class_, interface, name=u''):
     if not name:
         cname = class_.__name__
         cname = name
     if name and name in context:
         raise ValueError, u'Utility %s already registered!' % name
     utility = class_()
     context[cname] = utility
     registration = UtilityRegistration(name, interface, utility)
     key = context.registrationManager.addRegistration(registration)
     zapi.traverse(context.registrationManager, key).status =  ActiveStatus
     return utility

in setup code...

     from zope.app.intid.interfaces import IIntIds
     from zope.app.catalog.interfaces import ICatalog
     from zope.app.intid import IntIds
     from zope.app.catalog.catalog import Catalog

     _registerUtility(default, IntIds, IIntIds)
     _registerUtility(default, Catalog, ICatalog, u'my_catalog')

and then to make indexes registered, something like:

     from zope.app import zapi
     from zope.app.catalog.field import FieldIndex

     catalog = zapi.getUtility(ICatalog, u'my_catalog')
     catalog['something'] = FieldIndex('something', ISomeInterface)

_registerUtility is rather messy but it works..

Anyway, once you do get the catalog working, you may want to check out 
hurry.query, which makes querying the Zope 3 catalog a lot easier (in my 




More information about the Zope3-users mailing list