Greetings. I'd like to ask you how to grant a role to an istance of a "User" object. Maybe my code has major errors, but I am still a newbie and I am using Zope3 for my thesis.
In my application, when a User is created/deleted, I create/delete a Principal into/from the Principal Folder. It is not a sign-up scenario, the Users are created/deleted by a logged Principal with the "Administrator" role, who creates the account for the Users and picks a Role for them from the "Role Ids" vocabulary. An adapter is subscribed to (IUser, IObjectAdde/DeleteEvent); it extracts login, password and title (title is a sort of unique key that matches Principal and User) from the user to accomplish its task. My idea is that, when the visitor types his login and password and he is authenticated, he is automatically granted the Role assigned during the account creation. Here is the code responsible to granting the Role to the User @adapter( IUser, IObjectAddedEvent ) def f( user, event): (...) principal = InternalPrincipal( login=user.login, password=user.password, title=user.title ) prm = IPrincipalRoleManager( user ) prm.assignRoleToPrincipal( user.role, principal ) principalFolder[user.title] = principal the pau.authenticatorPlugins is the PrincipalFolder I create (and registerUtility) and populate in sync with the User addings/removals. the pau.credentialPlugins are "No Challenge if Authenticated" and "Session Credentials" Second question: is there an event to subscribe to that is triggered when a Principal is authenticathed? My need is to store the user.title in a Session annotation (I need it in various Viewlets) Thank you from a desperate student :) _______________________________________________ Zope3-users mailing list Zope3email@example.com http://mail.zope.org/mailman/listinfo/zope3-users