Part of lp.services.webapp
Almost everything in Launchpad relies on a security policy, in particular retrieving utilities and accessing attributes.
Zope obtains the security policy by looking at the 'interaction', which is a thread-local variable. If there is no interaction, one is likely to encounter an error like:
AttributeError("'thread._local' object has no attribute 'interaction'")
In Launchpad, we frequently refer to the state of having no interaction as being "logged out".
Because one needs an interaction to do practically anything, and because Launchpad allows anonymous access, it is possible to create an interaction (informally, "log in") for a mythical anonymous user.
The object representing the logged-in user is called the "principal", and the relationship between the principal and the interaction is called the "participation".
In Launchpad and in standard usage, the participation is the request and the principal is the requesting user. Although Zope has support for more than one of these, we only ever allow one.
There are test helpers in
See also lib/canonical/launchpad/doc/webapp-authorization.txt.
|Function||get_current_principal||Get the principal from the current interaction.|
|Function||setupInteraction||Sets up a new interaction with the given principal.|
|Function||setupInteractionByEmail||Setup an interaction using an email.|
|Function||setupInteractionForPerson||Setup a participation for a person.|
|Class||Participation||A very simple participation.|
|Class||InteractionExtras||Extra data attached to all interactions. See
|Function||get_interaction_extras||Return the active provider of
|Returns||The current principal if there is an interaction, None otherwise.|
The login gets added to the launch bag.
You can optionally pass in a participation to be used. If no participation is given, a Participation is used.
If the ANONYMOUS constant is supplied as the email, an interaction for the anonymous user will be used.
You can optionally pass in a participation to be used. If no participation is given, an empty participation is used.
If the participation provides IPublicationRequest, it must implement setPrincipal(), otherwise it must allow setting its principal attribute.
This is looked up from the interaction. If there is no interaction then return None.