[Grok-dev] Small problem removing roles from principals
Sebastian Ware
sebastian at urbantalk.se
Wed Sep 19 05:44:08 EDT 2007
I am having problems removing roles from principals. I am using the
following code to "refresh" the roles assigned to a principal:
def touch_user_roles(user):
pau = getUtility(IAuthentication)
principals = pau['principals']
role_manager = IPrincipalRoleManager(user)
role_manager.removeRoleFromPrincipal('prestatics.editor',
principals.prefix +
user.__name__)
role_manager.removeRoleFromPrincipal('prestatics.manager',
principals.prefix +
user.__name__)
if IWorkflowState(user).getState() == interfaces.PUBLISHED:
if user.role == 'Manager':
role_manager.assignRoleToPrincipal('prestatics.manager',
principals.prefix
+ user.__name__)
elif user.role == 'Editor':
role_manager.assignRoleToPrincipal('prestatics.editor',
principals.prefix
+ user.__name__)
If I remove calls to "removeRoleFromPrincipal" I can add roles
without any problems. What am I doing wrong with the call to
"removeRoleFromPrincipal"?
Mvh Sebastian
More information about the Grok-dev
mailing list