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__
    else:
        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 opinion):

http://codespeak.net/svn/z3/hurry/trunk

Regards,

Martijn
_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to