[Zope-dev] Pluggable Indexes and Splitters

Andy Dawkins andyd@nipltd.com
Tue, 31 Jul 2001 11:33:19 +0000


I have a small problem with Pluggable Indexes and Splitters which I
think is an oversight of the current design implementation.

The Details Bit:
Zope 2.4.0 (final)
Python 2.1

I can successfully create a new Splitter (called MySplitter) I add it to
availablesplitters, put it in its own directory in
PluginIndexes/TextIndex/Splitter/

Then I create a new vocabulary and MySplitter appear on the list of
splitters.  Fantastic thats great.

Next I create my own index.

This index is very similar to the TextIndex, so I copy the
PluginIndexes, rename it, remove the indexes I don't want to modify
(FieldIndex, KeywordIndex, PathIndex) and rename TextIndex to
MyTextIndex

I make the relevant changes to MyTextIndex, head back to the ZMI and add
an index using MyTextIndex.

All is fine.

Here is a quick diagram of my current directory structure (for those who
are easily lost)

/2.4.0_base/lib/python/Product/PluginIndexes/TextIndex/Splitter/MySpliter 
-  (MySplitter)
/MyInstance/Products/MyTextIndex/MyTextIndex  -  (MyTextIndex)

Now because MySplitter is completely useless when used with TextIndex
and because other zope instance's use the 2.4.0_base that don't need
MySplitter, I move MySplitter out of the
/PluginIndexes/TextIndex/Splitter folder and into /MyTextIndex/Splitter
folder.

I return the availablesplitters attribute in
/TextIndex/Splitter/__init__.py to what is should be and make the change
to my own /MyTextIndex/Splitter/__init__.py

Because MySplitter is the _only_ splitter that I want MyTextIndex to use
I remove all other splitters from the /MyTextIndex/Splitter/ folder, and
their relevant entries in availablesplitters.

Head back to the ZMI, Remove the catalog and start again.

New ZCatalog <click>, Create a vocabulary for me <click>, ok <click>
New Vocabulary <click>, Name it 'MyVocabulary' <tap><tap><tap>, Select
my splitter <STOP> My splitter isn't listed anymore.

And thats where the problem lies.

Deaper investigation reveals that inside
/2.4.0_base/lib/python/Products/ZCatalog/Vocabulary.py
Lies a single line which reads.
	from Products.PlugginIndexs.TextIndex.Vocabulary import *

So it _always_ uses the vocabulary in TextIndex, which always uses the
Splitters in TextIndex.
Oooops, This isn't very friendly, How am i supposed to create my own
Indexes with thier Own Splitters???????

1) I could change this file, But it is in a base zope folder so it will
screw all the Catalogs that use this base.
2) I could leave MySplitter in the /TextIndex/Splitter folder, But I
don't want a normal TextIndex to use this splitter.

Ideally I want PluggableIndexes to be able to have their own splitters.

-Andy Dawkins