index more than one contact per field
This commit is contained in:
parent
f8217576be
commit
5cc2079c6e
|
@ -196,18 +196,25 @@ def contactFuzzyIndexer(obj):
|
|||
v = getattr(obj, attr)
|
||||
if not v:
|
||||
continue
|
||||
v = v[0]
|
||||
if ':' in v:
|
||||
src = ContactsSource()
|
||||
try:
|
||||
r = src.fastGetTitleByToken(obj, v)
|
||||
except KeyError:
|
||||
return v.split(':')[1:]
|
||||
if not type(r) is unicode:
|
||||
r = unicode(r, 'utf-8')
|
||||
return r
|
||||
else:
|
||||
return v
|
||||
|
||||
# it may happen there are several items, merge all of them into a
|
||||
# single value
|
||||
result = []
|
||||
for contact in v:
|
||||
if ':' in contact:
|
||||
src = ContactsSource()
|
||||
try:
|
||||
r = src.fastGetTitleByToken(obj, contact)
|
||||
except KeyError:
|
||||
result.append(contact.split(':')[1:])
|
||||
continue
|
||||
if not type(r) is unicode:
|
||||
r = unicode(r, 'utf-8')
|
||||
result.append(r)
|
||||
else:
|
||||
result.append(contact)
|
||||
if result:
|
||||
return u' '.join(result)
|
||||
return None
|
||||
|
||||
grok.global_adapter(contactFuzzyIndexer, name="mailContactFuzzy")
|
||||
|
|
Reference in New Issue