Skip to content

Commit

Permalink
Merge pull request #8 from IMIO/wca
Browse files Browse the repository at this point in the history
add pas.plugins.imio compatible get_user_fullname to retrieve a user fullname
  • Loading branch information
odelaere committed Jun 14, 2021
2 parents 12131e7 + fe7ce10 commit 22c787b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/imio/helpers/content.py
Expand Up @@ -622,3 +622,21 @@ def object_ids(context, class_names):
if contained.__class__.__name__ in class_names:
res.append(contained.getId())
return res


def get_user_fullname(username):
"""Get fullname without using getMemberInfo that is slow slow slow..."""
acl_users = api.portal.get_tool('acl_users')
storages = [acl_users.mutable_properties._storage, ]
# if authentic is available check it first
if hasattr(acl_users, 'authentic'):
storages.insert(0, acl_users.authentic._useridentities_by_userid)

for storage in storages:
data = storage.get(username, None)
if data:
if hasattr(data, 'get') and data.get('fullname'):
return data.get('fullname')
else:
return data._identities['authentic-agents'].data['fullname']
return username

0 comments on commit 22c787b

Please sign in to comment.