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 anything.

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 import IIntIds
    from import ICatalog
    from import IntIds
    from import Catalog

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

and then to make indexes registered, something like:

    from import zapi
    from 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 opinion):


Zope3-users mailing list

Reply via email to