[Zope3-Users] Assigning programmatically a Role to a Principal

Thierry Florac thierry.florac at onf.fr
Tue May 12 06:18:39 EDT 2009


Le mardi 12 mai 2009,
  paftek <paftek at gmail.com> a écrit :
======================================================================
> I created a Role and a Permission affected to it :
> <role id="app.User" title="Utilisateur" />
> <permission id="app.Auth" title="Utilisateur authentifié" />
> <grant permission="app.Auth" role="app.User" />
> 
> My users are store in a PostgreSQL database, not in the ZODB.
> I use the Zope authentication system to return a PrincipalInfo when an
> user log in.
> 
> I do not know how to assign my "app.User" Role to the Principal who
> log in. I tried the following, without success :
> 
> @adapter(IAuthenticatedPrincipalCreated)
> def setPermission(event):
>     role_map = IPrincipalRoleManager(getSiteManager())
>     role_map.assignRoleToPrincipal('app.User', event.principal.id)
======================================================================

Hi,

What do you mean when you say "without success" ?
What do you get when you look at the "@@grant.html" view over your
context ??

Thierry
-- 
Chef de projets intranet/internet
Office National des Forêts - Département Informatique
2, Avenue de Saint-Mandé
75570 Paris Cedex 12
Tél. : 01 40 19 59 64
Fax. : 01 40 19 58 85
Mél. : thierry.florac at onf.fr
Web. : http://www.onf.fr



More information about the Zope3-users mailing list