somehow improve compatibility with the unicode mess :/
This commit is contained in:
parent
92461e09ae
commit
3cdaa260df
|
@ -156,24 +156,26 @@ class PrincipalSource(object):
|
|||
if isinstance(token, unicode):
|
||||
token = token.encode('utf-8')
|
||||
|
||||
type = result_dict.get('principal_type', 'user')
|
||||
object_type = result_dict.get('principal_type', 'user')
|
||||
value = result_dict.get('login', result_dict.get('groupid')) or id
|
||||
title = result_dict.get('title') or value
|
||||
|
||||
|
||||
# Attempt to get a title from the fullname if not set. Unfortunately,
|
||||
# source_users doesn't have fullname, and mutable_properties doesn't
|
||||
# match on login name or id when searching.
|
||||
|
||||
if title == value:
|
||||
if type == 'user':
|
||||
if object_type == 'user':
|
||||
user = self.acl_users.getUserById(id)
|
||||
if user is not None:
|
||||
try:
|
||||
# XXX: user.getProperty() is PlonePAS specfic
|
||||
title = user.getProperty('fullname') or value
|
||||
if type(title) not in (str, unicode):
|
||||
title = value
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
|
||||
#
|
||||
# Seems the groups source is a bit more intelligent, so we don't
|
||||
# need this.
|
||||
|
@ -186,7 +188,12 @@ class PrincipalSource(object):
|
|||
# except AttributeError:
|
||||
# pass
|
||||
|
||||
return PrincipalTerm(value=value, type=type, token=token, title=title)
|
||||
if type(value) is not unicode:
|
||||
value = unicode(value, 'utf-8')
|
||||
if type(title) is not unicode:
|
||||
title = unicode(title, 'utf-8')
|
||||
|
||||
return PrincipalTerm(value=value, type=object_type, token=token, title=title)
|
||||
|
||||
@property
|
||||
def _search(self):
|
||||
|
|
Reference in New Issue