[Zope3-Users] Custom index implementation

Tom Dossis td at yoma.com.au
Mon Jun 5 18:11:40 EDT 2006


Achim Domma wrote:
> Hi,
> 
> I try to implement a custom index to be inserted into a catalog. I look
> at the code and it seems to me, that I only have to derive my interface
> from ICatalogIndex. I have defined my interface like this:
> 
> class ITestIndex(zope.app.catalog.interfaces.ICatalogIndex):
>     pass
> 
> Then I have implemented a class which implements this interface and have
> it registerd like this:
> 
> <class class=".Workspace.TestIndex">
>     <require
>         permission="zope.ManageServices"
>     interface=".interfaces.ITestIndex    
>              zope.index.interfaces.IStatistics"
>         set_schema=".interfaces.ITestIndex"
>     />
> </class>
> 
> If I restart zope and go to my catalog, I still can only add FieldIndex
> and TestIndex. What else do I have to do, to implement a custom index?

You need to specify an addMenuItem directive and associated "view" in
your package browser zcml to enable you to add your index objects via
the ZMI.  Look at zope/app/catalog/browser/configure.zcml as a starting
point, e.g.

<addform
    name="AddTestIndex"
    label="Add a test index"
    schema="..interfaces.ITestIndex"
    permission="zope.ManageServices"
    content_factory="..WorkSpace.TestIndex"
    arguments="field_name"
    keyword_arguments="interface field_callable"
    />

 <addMenuItem
    title="Test Index"
    description="My Test Index"
    class="..Workspace.TestIndex"
    permission="zope.ManageServices"
    view="AddTestIndex"
   />


More information about the Zope3-users mailing list