Change Request in TextIndex implementation
I have a product that uses a Catalogs (just plain, not ZCatalogs) for indexing objects. It uses several Catalogs each of which share a Vocabulary. This was easy to do in 2.3, however, some code in 2.4 makes this a pain in the rear. Specifically line 204 of TextIndex.py, which tries to get the vocabulary lexicon from the parent ZCatalog like so: self._lexicon = self.aq_parent.aq_parent[self.vocabulary_id].getLexicon() In a world of implicit aquisition, this strikes me as very bad form. For this to work, the vocabulary must reside in the parent of the parent of the index, which must be a mapping object for it to find it. This is not the case with my implementation, in fact the vocabulary can be basically anywhere above the index. Of course, I could simply pass in the lexicon when the Index is instantiated. This is great and wonderful, except, I would like to support Zope 2.3 in as seemless a way possible. Writing crap like this bothers me (although I have little choice at this point methinks): try: index = TextIndex('spam', lexicon=eggs) except: index = 'TextIndex' Can't we change the above line to be something like this, which does not depend on a specific hierarchy? self._lexicon = self.aq_parent.getattr(self.vocabulary_id).getLexicon() That would make me very happy... -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
Casey Duncan wrote:
In a world of implicit aquisition, this strikes me as very bad form. For this to work, the vocabulary must reside in the parent of the parent of the index, which must be a mapping object for it to find it. This is not the case with my implementation, in fact the vocabulary can be basically anywhere above the index.
Yeah, I put a bug in the tracker kindof related to this. You'll find that if you add a vocabulary above the ZCatalogs in the acquisition path, you won't get to choose which splitter you use since that choice requires an attribute to be present that is defined in the __init__ method of ZCatalog. This also means that you get the same efefct if you try and add a new vocabulary to an old ZCatalog instance :-(
Of course, I could simply pass in the lexicon when the Index is instantiated. This is great and wonderful, except, I would like to support Zope 2.3 in as seemless a way possible. Writing crap like this bothers me (although I have little choice at this point methinks):
The PluginIndex stuff does seem a bit scrappy in places :-S I don't like the Indexes tab, jumping context like that doesn't work for me... There also seem to be an awful lot of exec statements in the PluginIndexes code which always make me nervous, and now that I've got up close an personal with it, it seems to be very difficult to do what I actually want; create news types of indexes, splitters, lexicons, vocabularies, etc by subclassing the ones already there. What do other people think? cheers, Chris Women have bad hair days, I have bad Zope days, this is one of them ;-)
----- Original Message ----- From: "Casey Duncan" <cduncan@kaivo.com> To: <zope-dev@zope.org> Sent: Dienstag, 31. Juli 2001 11:28 Subject: [Zope-dev] Change Request in TextIndex implementation
I have a product that uses a Catalogs (just plain, not ZCatalogs) for indexing objects. It uses several Catalogs each of which share a Vocabulary. This was easy to do in 2.3, however, some code in 2.4 makes this a pain in the rear. Specifically line 204 of TextIndex.py, which tries to get the vocabulary lexicon from the parent ZCatalog like so:
self._lexicon = self.aq_parent.aq_parent[self.vocabulary_id].getLexicon()
In a world of implicit aquisition, this strikes me as very bad form. For this to work, the vocabulary must reside in the parent of the parent of the index, which must be a mapping object for it to find it. This is not the case with my implementation, in fact the vocabulary can be basically anywhere above the index.
Of course, I could simply pass in the lexicon when the Index is instantiated. This is great and wonderful, except, I would like to support Zope 2.3 in as seemless a way possible. Writing crap like this bothers me (although I have little choice at this point methinks):
try: index = TextIndex('spam', lexicon=eggs) except: index = 'TextIndex'
Can't we change the above line to be something like this, which does not depend on a specific hierarchy?
self._lexicon = self.aq_parent.getattr(self.vocabulary_id).getLexicon()
That would make me very happy...
Be happy. I fixed the problem in the CVS. Andreas
participants (3)
-
Andreas Jung -
Casey Duncan -
Chris Withers