[Zope3-dev] How to get Principals Roles? Owner-Role?

Stephan Richter stephan.richter@tufts.edu
Sat, 14 Jun 2003 16:39:06 -0400


On Saturday 14 June 2003 16:12, Administrator wrote:
> Hi Again!
>
> How do I get the roles of a given principal?
>
> This code, I have stolen from NewsSite doesnt work for me, because a
> Principal doesn't have any methode getRoles()::
>
> 	authsvc = getService(self.context, Authentication)
>         authsvc.authenticate(self.request)
>         principal = getSecurityManager().getPrincipal()
>         return {'id' : principal.getId(),
>                 'title' : principal.getTitle(),
>                 'roles' : principal.getRoles()
>                }
>
> I had a look through Zopes Sources, and found: only User has such a
> methode. How do I get Roles for a Principal, or how do I get a User
> instead of a Principal?

The request has a 'user' attribute, which will give you all the desired 
information.

> Is there such a thing as a role Owner or Creator for an object, so that
> the creator may have some special rights, others don't have?

I am not sure whether this is implemented already.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training