[Zope-Coders] Keyword Indexes misbehaving?

Sidnei da Silva sidnei@x3ng.com.br
Sun, 2 Mar 2003 12:29:08 -0300


Apparently, Casey's fix for bug #828 caused a new bug :(
 
http://cvs.zope.org/Zope/lib/python/Products/PluginIndexes/KeywordIndex/KeywordIndex.py.diff?r1=1.11&r2=1.11.6.1

The CMFCollector has a field that is being indexed as a keyword index, but the
method being indexed returns a single integer. It fails on the 'for' added by
Casey with a 'loop over non-sequence'. 

Im not sure if the KeywordIndex is supposed to index only string keywords, in
which case CMFCollector needs to be fixed, or if its supposed to index lists of
any value, in which case i suggest changing the method to:

    def _get_object_keywords(self,obj):
	newKeywords = getattr(obj, self.id, ())
        if callable(newKeywords):
            newKeywords = newKeywords()
	if type(newKeywords) not in [TupleType, ListType]:
            newKeywords = (newKeywords, )
	# Uniqueify keywords                                                    	     
  unique = {}
	for k in newKeywords:
	        unique[k] = None
	newKeywords = unique.keys()
        return newKeywords

[]'s
-- 
Sidnei da Silva (dreamcatcher) <sidnei@x3ng.com.br>
X3ng Web Technology <http://www.x3ng.com.br>