Changeset 7173


Ignore:
Timestamp:
22 Nov 2011, 20:27:49 (13 years ago)
Author:
Henrik Bettermann
Message:

Automatically set global PortalUser? role when user account is created. Thus all users get view permissions for the academic section.

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

Legend:

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

    r7172 r7173  
    216216def handle_account_added(account, event):
    217217    """When an account is added, the local owner role and the global
    218     PortalUser rolemust be set.
    219     """
    220     # First we have to set the local owner role of the account object
    221     role_manager = IPrincipalRoleManager(account)
    222     role_manager.assignRoleToPrincipal(
     218    PortalUser role must be set.
     219    """
     220    # We set the local Owner role
     221    role_manager_account = IPrincipalRoleManager(account)
     222    role_manager_account.assignRoleToPrincipal(
    223223        'waeup.local.Owner', account.name)
    224     # Then we have to notify the user account that the local role
     224    # We set the global PortalUser role
     225    site = grok.getSite()
     226    role_manager_site = IPrincipalRoleManager(site)
     227    role_manager_site.assignRoleToPrincipal(
     228        'waeup.PortalUser', account.name)
     229    # Finally we have to notify the user account that the local role
    225230    # of the same object has changed
    226231    notify(LocalRoleSetEvent(
  • main/waeup.sirp/trunk/src/waeup/sirp/authentication.txt

    r7172 r7173  
    4040  >>> root['app']['users'].addAccount(alice)
    4141
    42 See ``users.txt`` for details about the UsersContainer we use here.
     42See ``userscontainer.txt`` for details about the UsersContainer we use here.
    4343
    4444Users and local roles
     
    4646
    4747Accounts also hold infos about local roles assigned to a user. In the
    48 beginning, users have only the local owner role of their own account object:
     48beginning, users have the local owner role of their own account object:
    4949
    5050  >>> alice.getLocalRoles()
    5151  {'waeup.local.Owner': [<waeup.sirp.authentication.Account object at 0x...>]}
     52
     53Users have also got the global PortalUser role:
     54
     55  >>> alice.getRoles()
     56  ['waeup.PortalUser']
    5257
    5358We can tell an account, that Alice got some role for another object:
Note: See TracChangeset for help on using the changeset viewer.