[Zope-Coders] Patch for KeywordIndexes

Sidnei da Silva sidnei@x3ng.com
Fri, 30 May 2003 18:21:23 -0300


--7AUc2qLy4jB3hD7Z
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

If no one object (or if someone provides a better way to do this) I
would like to apply the following patch for KeywordIndexes on
2_6-branch and HEAD. Its just completely annoying that this worked
before, and now its so stupidly broken :(

[]'s
-- 
Sidnei da Silva (dreamcatcher) <sidnei@x3ng.com.br>
X3ng Web Technology <http://www.x3ng.com.br>
GNU/Linux user 257852
Debian GNU/Linux 3.0 (Sid) 2.4.20-powerpc ppc

Sorry.  I just realized this sentance makes no sense :)
	-- Ian Main

--7AUc2qLy4jB3hD7Z
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="keywordindex.patch"

Index: lib/python/Products/PluginIndexes/KeywordIndex/KeywordIndex.py
===================================================================
RCS file: /cvs-repository/Zope/lib/python/Products/PluginIndexes/KeywordIndex/KeywordIndex.py,v
retrieving revision 1.11.6.1
diff -u -r1.11.6.1 KeywordIndex.py
--- lib/python/Products/PluginIndexes/KeywordIndex/KeywordIndex.py	28 Feb 2003 15:58:18 -0000	1.11.6.1
+++ lib/python/Products/PluginIndexes/KeywordIndex/KeywordIndex.py	30 May 2003 21:20:15 -0000
@@ -88,14 +88,16 @@
         newKeywords = getattr(obj, self.id, ())
         if callable(newKeywords):
             newKeywords = newKeywords()
-        if hasattr(newKeywords,'capitalize'): # is it string-like ?
+        try:
+            # Test for iterability
+            for n in newKeywords: pass
+        except TypeError:
             newKeywords = (newKeywords, )
-        else:
-            # Uniqueify keywords
-            unique = {}
-            for k in newKeywords:
-                unique[k] = None
-            newKeywords = unique.keys()
+        # Uniqueify keywords
+        unique = {}
+        for k in newKeywords:
+            unique[k] = None
+        newKeywords = unique.keys()
         return newKeywords
 
     def unindex_objectKeywords(self, documentId, keywords):

--7AUc2qLy4jB3hD7Z--