Changeset 6202 for main


Ignore:
Timestamp:
26 May 2011, 23:34:04 (14 years ago)
Author:
uli
Message:

#37

Location:
main/waeup.sirp/trunk/src/waeup/sirp
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/authentication.txt

    r6180 r6202  
    111111   {}
    112112
     113If one notifies the machinery of a local role removal for an object
     114that cannot have local roles, this will cause no trouble:
     115
     116   >>> mycontext = None #object()
     117   >>> notify(LocalRoleSetEvent(
     118   ...   mycontext, 'waeup.PortalManager', 'bob', granted=False
     119   ... )) is None
     120   True
     121
    113122Logging in via side bar
    114123=======================
  • main/waeup.sirp/trunk/src/waeup/sirp/permissions.py

    r6198 r6202  
    147147    roles map of the `context` object.
    148148    """
    149     role_map = IPrincipalRoleMap(context)
     149    try:
     150        role_map = IPrincipalRoleMap(context)
     151    except TypeError:
     152        # no map no roles.
     153        raise StopIteration
    150154    for local_role, user_name, setting in role_map.getPrincipalsAndRoles():
    151155        user = grok.getSite()['users'].get(user_name,None)
  • main/waeup.sirp/trunk/src/waeup/sirp/permissions.txt

    r6198 r6202  
    5454    >>> list(getWAeUPRoleNames())
    5555    [u'waeup.ApplicationsOfficer', u'waeup.PortalManager', u'waeup.PortalUser']
     56
     57:func:`get_users_with_local_roles`
     58----------------------------------
     59
     60We can get all users and their roles for a certain context
     61object. This even works for objects that cannot have local roles as
     62they are not stored in the ZODB:
     63
     64    >>> from waeup.sirp.permissions import get_users_with_local_roles
     65    >>> mycontext = object()
     66    >>> people_and_roles = get_users_with_local_roles(mycontext)
     67    >>> people_and_roles
     68    <generator object at 0x...>
     69
     70In this case, the result is empty:
     71
     72    >>> people_and_roles = list(people_and_roles)
     73    >>> people_and_roles
     74    []
  • main/waeup.sirp/trunk/src/waeup/sirp/users.py

    r6180 r6202  
    6363@grok.subscribe(Interface, grok.IObjectRemovedEvent)
    6464def handle_local_roles_on_obj_removal(obj, event):
    65     role_map = IPrincipalRoleMap(obj)
     65    try:
     66        role_map = IPrincipalRoleMap(obj)
     67    except TypeError:
     68        # no map, no roles to remove
     69        return
    6670    for local_role, user_name, setting in role_map.getPrincipalsAndRoles():
    6771        notify(LocalRoleSetEvent(
Note: See TracChangeset for help on using the changeset viewer.