[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/KeywordIndex - KeywordIndex.py:1.6

Toby Dickenson tdickenson@geminidataloggers.com
Mon, 11 Mar 2002 08:16:32 -0500


Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/KeywordIndex
In directory cvs.zope.org:/tmp/cvs-serv10762/lib/python/Products/PluginIndexes/KeywordIndex

Modified Files:
	KeywordIndex.py 
Log Message:
merged toby-subclass-index-branch: Collector 284: KeywordIndex and FieldIndex subclassing

=== Zope/lib/python/Products/PluginIndexes/KeywordIndex/KeywordIndex.py 1.5 => 1.6 ===
         # 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'"""