Pluggable Indexes and Splitters
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
Andy, Splitters belong to the vocabularies/lexicons. The TextIndex just aquires the Splitter from the corresponding Lexicon. Currently there is no official way to make Splitters available only a available to dedicated components. A more sophisticated approach would be to register them in the registry in a similar way PluginIndexes are registered. One workaround for you *might* to create your own vocabulary type by subclassing one of the exstings vocabularies and adjust the Splitter selection to your needs. Andreas Zope Corporation ----- Original Message ----- From: "Andy Dawkins" <andyd@nipltd.com> To: <zope-dev@zope.org> Sent: Dienstag, 31. Juli 2001 06:33 Subject: [Zope-dev] Pluggable Indexes and Splitters
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.
Andreas Ok call me stupid but I really don't see how subclassing the vocabulary will help in this situation. The ZCatalog uses the Vocabulary in the Products/ZCatalog Folder, Which is 'HardCoded' to use the Vocabulary in the Products/PluginIndexes/TextIndex folder. (I am guess this is for backward compatibility issues) I can't change any of this code because there are systems currently running on this Zope Base which use catalogs and the fact that it is backwards compatible is really important. I don't see how creating another Vocabulary would change any of this. Am I stupid? (Be fair) -Andy Andreas Jung wrote:
Andy,
Splitters belong to the vocabularies/lexicons. The TextIndex just aquires the Splitter from the corresponding Lexicon. Currently there is no official way to make Splitters available only a available to dedicated components. A more sophisticated approach would be to register them in the registry in a similar way PluginIndexes are registered. One workaround for you *might* to create your own vocabulary type by subclassing one of the exstings vocabularies and adjust the Splitter selection to your needs.
Andreas Zope Corporation
----- Original Message ----- From: "Andy Dawkins" <andyd@nipltd.com> To: <zope-dev@zope.org> Sent: Dienstag, 31. Juli 2001 06:33 Subject: [Zope-dev] Pluggable Indexes and Splitters
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.
Andreas Jung wrote:
aquires the Splitter from the corresponding Lexicon. Currently there is no official way to make Splitters available only to dedicated components.
I think the opposite is true, Splitters and Volcabularies seem to be limited to only being used by TextIndexes within PlugginIndexes. I just put a bug in the collector about one aspect of this. I think Vocabularies might be generically useful in Zope, not just to ZCatalog, likewise splitters. I'd love to be able to do: context.mySplitter.split('the quíck brown f0x') ...for example. But, it does seem exraordinarily hard to register new types of splitter. Currently, the only way I can think to do it would be something like: import MySplitter from Products.PluginIndexes.TextIndex import Splitter aS = Splitter.availableSplitters # why isn't availableSplitters a dictionary?! aS = aS + ("MySplitter","My Special Funky Splitter") Splitter.availableSplitters = aS # worse still... setattr(Splitter,'MySplitter',MySplitter) ...and I'm not even sure that'd work :( Maybe Vocabularies should be in their own Product and maybe (although maybe not) Splitters and Lexicons should be in their own Products too? cheers, Chris
Chris Thanks, That makes much more sense. Still not sure how you could make it work due to previously mentioned 'hardcoding' but the theory sounds spot on. -Andy Chris Withers wrote:
Andreas Jung wrote:
aquires the Splitter from the corresponding Lexicon. Currently there is no official way to make Splitters available only to dedicated components.
I think the opposite is true, Splitters and Volcabularies seem to be limited to only being used by TextIndexes within PlugginIndexes. I just put a bug in the collector about one aspect of this.
I think Vocabularies might be generically useful in Zope, not just to ZCatalog, likewise splitters.
I'd love to be able to do:
context.mySplitter.split('the quíck brown f0x')
...for example.
But, it does seem exraordinarily hard to register new types of splitter. Currently, the only way I can think to do it would be something like:
import MySplitter
from Products.PluginIndexes.TextIndex import Splitter
aS = Splitter.availableSplitters # why isn't availableSplitters a dictionary?! aS = aS + ("MySplitter","My Special Funky Splitter") Splitter.availableSplitters = aS
# worse still... setattr(Splitter,'MySplitter',MySplitter)
...and I'm not even sure that'd work :(
Maybe Vocabularies should be in their own Product and maybe (although maybe not) Splitters and Lexicons should be in their own Products too?
cheers,
Chris
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
participants (3)
-
Andreas Jung -
Andy Dawkins -
Chris Withers