From 3bd66e32645adf19ed714728dc62cc0d66454775 Mon Sep 17 00:00:00 2001 From: Gaetan Delannay Date: Wed, 26 Sep 2012 23:32:57 +0200 Subject: [PATCH] [gen] Indexing machinery: bugfixes (Ref index). --- gen/__init__.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/gen/__init__.py b/gen/__init__.py index 9426309..9a2223c 100644 --- a/gen/__init__.py +++ b/gen/__init__.py @@ -1916,22 +1916,21 @@ class Ref(Type): def getFormattedValue(self, obj, value): return value - def getIndexType(self): return 'TextIndex' + def getIndexType(self): return 'ListIndex' def getIndexValue(self, obj, forSearch=False): '''Value for indexing is the list of UIDs of linked objects. If - p_forSearch is True, it will return a "string" version made of the - titles of linked objects.''' + p_forSearch is True, it will return a list of the linked objects' + titles instead.''' if not forSearch: - res = getattr(obj.aq_base, self.name, '') - if res: res = ' '.join(res) + res = getattr(obj.aq_base, self.name, []) + if res: + # The index does not like persistent lists. + res = list(res) return res else: - # For the global search: concatenate titles of linked objects - titles = [] - for obj in self.getValue(type='objects'): - titles.append(obj.title) - return ' '.join(titles) + # For the global search: return linked objects' titles. + return [o.title for o in self.getValue(type='objects')] def validateValue(self, obj, value): if not self.link: return None