[Zope-dev] Change Request in TextIndex implementation

Andreas Jung andreas@zope.com
Tue, 31 Jul 2001 15:53:55 -0500


----- 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