From aee438470028fbf457512a8072a035f909c395f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Tue, 29 Jan 2013 14:24:05 +0100 Subject: [PATCH] indexers: properly encode the bytestring returned by Title() --- src/collective/dms/thesaurus/indexers.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/collective/dms/thesaurus/indexers.py b/src/collective/dms/thesaurus/indexers.py index 2a84793..80e0119 100644 --- a/src/collective/dms/thesaurus/indexers.py +++ b/src/collective/dms/thesaurus/indexers.py @@ -12,8 +12,10 @@ class IDmsKeywordIndexer(Interface): def dmskeyword_searchable_text(obj): indexed_fields = [] title = obj.Title() - if isinstance(title, unicode): - title = title.encode('utf-8') + if not isinstance(title, unicode): + # Title() is a CMF-style accessor, it will therefore a return a + # utf8-encoded bytestring; encode it back as an unicode string. + title = unicode(title, 'utf-8') indexed_fields.append(title) # equivs = obj.get_equivs() # for equiv in equivs: