[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/KeywordIndex - KeywordIndex.py:1.5.24.1
Toby Dickenson
tdickenson@geminidataloggers.com
Mon, 11 Mar 2002 08:14:13 -0500
Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/KeywordIndex
In directory cvs.zope.org:/tmp/cvs-serv9701/lib/python/Products/PluginIndexes/KeywordIndex
Modified Files:
Tag: toby-index-subclass-branch
KeywordIndex.py
Log Message:
collector 284: KeywordIndex and FieldIndex subclassing
=== Zope/lib/python/Products/PluginIndexes/KeywordIndex/KeywordIndex.py 1.5 => 1.5.24.1 ===
# we'll do so.
- newKeywords = getattr(obj, self.id, ())
- if callable(newKeywords):
- newKeywords = newKeywords()
-
- if type(newKeywords) is StringType:
- newKeywords = (newKeywords, )
+ newKeywords = self._get_object_keywords(obj)
oldKeywords = self._unindex.get(documentId, None)
@@ -96,6 +91,14 @@
self.insertForwardIndexEntry(kw, documentId)
return 1
+ def _get_object_keywords(self,obj):
+ newKeywords = getattr(obj, self.id, ())
+ if callable(newKeywords):
+ newKeywords = newKeywords()
+ if hasattr(newKeywords,'capitalize'): # is it string-like ?
+ newKeywords = (newKeywords, )
+ return newKeywords
+
def unindex_objectKeywords(self, documentId, keywords):
""" carefully unindex the object with integer id 'documentId'"""