[Zope3-Users] Assigning roles to principals

mats.nordgren mats at ronin-group.org
Wed Jun 14 10:35:47 EDT 2006


Frank,

Try this:

role_map = IPrincipalRoleManager(context) <== For example root of site.
role_map.assignRoleToPrincipal(u'mpgsite.Authenticated', principal_id)

I use the above code in an event handler when a site has been created. 
Instead of specifying the user I specify a group and then add each new member
to said group with this code.

group = component.getUtility(IGroupInformation, name='Members')
group.principals += (principal.id,)

Sincerely,

Mats
		

On Wed, 14 Jun 2006 16:08:48 +0200, Frank Burkhardt wrote
> Hi,
> 
> I implemented a small IAuthenticatorPlugin which manages a list of
> principals. Those principals dont seem to have any global 
> permissions. I zcml-registered a role and a permission ( both are named
> 'mpgsite.Authenticated' ) and would like all of my principals the 
> role to be assigned to.
> 
> I tried to do
> 
>  principalRoleManager.assignRoleToPrincipal(
>    'mpgsite.Authenticated',
>    principal_id,
>    check=False
>  )
> 
> whenever a principal is created but it doesn't seem to help. How 
> could I solve this problem? Is there a chance to map a an arbitrary 
> permission to the authenticatedGroup ?
> 
> <grant permission="mpgsite.Authenticated" 
> principal="zope.Authenticated" />
> 
> didn't work ("Undefined principal id").
> 
> Regards,
> 
> Frank
> 
> _______________________________________________
> Zope3-users mailing list
> Zope3-users at zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users



More information about the Zope3-users mailing list