[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/KeywordIndex - KeywordIndex.py:1.11.30.2
Andreas Jung
andreas@andreas-jung.com
Tue, 26 Nov 2002 12:22:42 -0500
Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/KeywordIndex
In directory cvs.zope.org:/tmp/cvs-serv17740/KeywordIndex
Modified Files:
Tag: ajung-oneindex-multipleattributes-branch
KeywordIndex.py
Log Message:
added multi-attribute indexing for KeywordIndexes
=== Zope/lib/python/Products/PluginIndexes/KeywordIndex/KeywordIndex.py 1.11.30.1 => 1.11.30.2 ===
--- Zope/lib/python/Products/PluginIndexes/KeywordIndex/KeywordIndex.py:1.11.30.1 Sun Nov 17 06:14:56 2002
+++ Zope/lib/python/Products/PluginIndexes/KeywordIndex/KeywordIndex.py Tue Nov 26 12:22:41 2002
@@ -41,7 +41,7 @@
This should have an _apply_index that returns a relevance score
"""
- def index_object(self, documentId, obj, threshold=None):
+ def _index_object(self, documentId, obj, threshold=None, attr=''):
""" index an object 'obj' with integer id 'i'
Ideally, we've been passed a sequence of some sort that we
@@ -54,7 +54,7 @@
# attribute we're interested in. If the attribute is callable,
# we'll do so.
- newKeywords = self._get_object_keywords(obj)
+ newKeywords = self._get_object_keywords(obj, attr)
oldKeywords = self._unindex.get(documentId, None)
@@ -84,20 +84,14 @@
self.insertForwardIndexEntry(kw, documentId)
return 1
- def _get_object_keywords(self,obj):
- newKeywords = getattr(obj, self.id, ())
+ def _get_object_keywords(self, obj, attr):
+ newKeywords = getattr(obj, attr, ())
if callable(newKeywords):
newKeywords = newKeywords()
if hasattr(newKeywords,'capitalize'): # is it string-like ?
newKeywords = (newKeywords, )
return newKeywords
-
- def getIndexSourceNames(self):
- """ return name of indexed attributes """
- return (self.id, )
-
-
def unindex_objectKeywords(self, documentId, keywords):
""" carefully unindex the object with integer id 'documentId'"""
@@ -124,7 +118,8 @@
manage_addKeywordIndexForm = DTMLFile('dtml/addKeywordIndex', globals())
-def manage_addKeywordIndex(self, id, REQUEST=None, RESPONSE=None, URL3=None):
+def manage_addKeywordIndex(self, id, extra=None,
+ REQUEST=None, RESPONSE=None, URL3=None):
"""Add a keyword index"""
- return self.manage_addIndex(id, 'KeywordIndex', extra=None, \
+ return self.manage_addIndex(id, 'KeywordIndex', extra=extra, \
REQUEST=REQUEST, RESPONSE=RESPONSE, URL1=URL3)