Martijn Faassen wrote:
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
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..
From a quick glans at your code the notisable difference is
that I don't call zapi.getUtility(ICatalog, u'my_catalog') to get the
catalog, that just might do the trick. (I jsut grab the catalog from the
I'll let you know when I get a chance to test it.
Does you code for adding catalogs and adding fields get called
in the same request?
Mine does, it gets called right after each other, and I'm thinking
in the lines of that there is something that doesn't get setup in
the correct order, which is why I think getUtility might work better.
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
I'll check it out :-)
Johan Carlsson Tel: + 46 8 31 24 94
Colliberty Mob: + 46 70 558 25 24
Torsgatan 72 Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
Zope3-users mailing list