adapt to get_full_title() returning unicode objects

This commit is contained in:
Frédéric Péters 2013-05-02 13:28:30 +02:00
parent 090c94e9cd
commit 5a766ca70a
1 changed files with 9 additions and 2 deletions

View File

@ -62,8 +62,15 @@ class ContactSource(ObjPathSource):
value = brain._unrestrictedGetObject()
else:
value = brain.getPath()[len(self.portal_path):]
full_title = brain.get_full_title or brain.Title or brain.id
return Term(value, token=brain.getPath(), title=full_title.decode('utf8'), brain=brain)
if brain.get_full_title:
full_title = brain.get_full_title
elif type(brain.Title) is unicode:
full_title = brain.Title
elif brain.Title:
full_title = unicode(brain.Title, 'utf-8')
else:
full_title = unicode(brain.id)
return Term(value, token=brain.getPath(), title=full_title, brain=brain)
def tokenToPath(self, token):
"""For token='/Plone/a/b', return '/a/b'