[Grok-dev] remove roles vom principal

Sebastian Ware sebastian at urbantalk.se
Tue Sep 23 08:36:03 EDT 2008


I just happened to look at the code first :)

Mvh Sebastian

23 sep 2008 kl. 13.57 skrev Jens Adner:

> ja, that's working. All roles are now removed. I saw this function in
> the interface description, but I'm confused. "unset" sounds more as
> unsetting the role just like the function "removeFrom..." do it.
>
> Thanks for your help!
>
> Jens
>
> Sebastian Ware schrieb:
>> There is something called:
>>
>>      def unsetRoleForPrincipal(role_id, principal_id):
>>        """Unset the role for the principal."""
>>
>> I don't know if it is available in the code below, but you could try.
>> The general way to learn more about how different components work is
>> really to look at the source code. Go to your egg-folder and find the
>> folder
>>
>>  zope.securitypolicy
>>
>> You will get many hints by looking at the different tests and  
>> doctests.
>> Examining the interfaces and actual code is quite useful too.
>>
>> Mvh Sebastian
>>
>> 23 sep 2008 kl. 12.07 skrev Jens Adner:
>>
>>> Hello,
>>>
>>> I did assign three roles  to my ldap principal, and remove two of  
>>> them
>>> later again:
>>>
>>> [(u'mysite.Member', PermissionSetting: Deny), (u'mysite.Member3',
>>> PermissionSetting: Deny), (u'mysite.Member2', PermissionSetting:  
>>> Allow)]
>>>
>>> I do this by removing all roles for a principal first and assign a
>>> specific role to this principal in a second step.
>>>
>>> This is my code for removing:
>>>
>>> prm = IPrincipalRoleManager(app)
>>> ## first remove all roles from principal
>>> rolesForRemove=prm.getRolesForPrincipal(principal.id)
>>> for role in rolesForRemove:
>>>  prm.removeRoleFromPrincipal(role[0],principal.id)
>>>
>>> My question is, how can I remove these roles forever, the function  
>>> above
>>> does not erase the roles, just setting them to "Deny".
>>>
>>> Maybe this is a feature and I did not understand it ;-)
>>>
>>> Regards,
>>> Jens
>>>
>>> -- 
>>> ++++++++ Jens Adner IuK-Zentrum Fachhochschule Schmalkalden +++++++ 
>>> ++
>>> ++++++++ Fon: +49 3683 6889201  Fax: +49 3683 6889499 +++++++++++++ 
>>> ++
>>> ++++++++     Jabber: adnus at jabber.ccc.de  +++++++++++++++++++++++++ 
>>> ++
>>> _______________________________________________
>>> Grok-dev mailing list
>>> Grok-dev at zope.org
>>> http://mail.zope.org/mailman/listinfo/grok-dev
>>
>
> -- 
> ++++++++ Jens Adner IuK-Zentrum Fachhochschule Schmalkalden +++++++++
> ++++++++ Fon: +49 3683 6889201  Fax: +49 3683 6889499 +++++++++++++++
> ++++++++     Jabber: adnus at jabber.ccc.de  +++++++++++++++++++++++++++
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> http://mail.zope.org/mailman/listinfo/grok-dev



More information about the Grok-dev mailing list