Changeset 9309 for main/waeup.kofa/trunk/src
- Timestamp:
- 7 Oct 2012, 21:49:12 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/permissions.py
r9303 r9309 360 360 local_role_title = local_role_title, 361 361 setting = setting) 362 363 def get_users_with_role(role, context): 364 """Get a list of dicts representing the usres who have been granted 365 a role for `context`. 366 """ 367 try: 368 role_map = IPrincipalRoleMap(context) 369 except TypeError: 370 # no map no roles. 371 raise StopIteration 372 for user_name, setting in role_map.getPrincipalsForRole(role): 373 user = grok.getSite()['users'].get(user_name,None) 374 user_title = getattr(user, 'title', user_name) 375 user_email = getattr(user, 'email', None) 376 yield dict(user_name = user_name, 377 user_title = user_title, 378 user_email = user_email, 379 setting = setting) -
main/waeup.kofa/trunk/src/waeup/kofa/permissions.txt
r9300 r9309 89 89 >>> people_and_roles 90 90 [] 91 92 :func:`get_users_with_role` 93 --------------------------- 94 95 We can get all users with a specific role for a certain context 96 object: 97 98 >>> from waeup.kofa.permissions import get_users_with_role 99 >>> mycontext = object() 100 >>> people = get_users_with_role('waeup.portalManager', mycontext) 101 >>> people 102 <generator object...at 0x...> 103 104 In this case, the result is empty: 105 106 >>> people = list(people) 107 >>> people 108 []
Note: See TracChangeset for help on using the changeset viewer.