-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged trunk to branch. I still ahve 4 ftests failing, but I suspect, it
will be fixed once I merge the changes of the last three days (hopefully).
- Loading branch information
Showing
14 changed files
with
908 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
==================== | ||
Login/Logout Snippet | ||
==================== | ||
|
||
The class LoginLogout: | ||
|
||
>>> from zope.app.security.browser.auth import LoginLogout | ||
|
||
is used as a view to generate an HTML snippet suitable for logging in or | ||
logging out based on whether or not the current principal is authenticated. | ||
|
||
When the current principal is unauthenticated, it provides | ||
IUnauthenticatedPrincipal: | ||
|
||
>>> from zope.app.security.interfaces import IUnauthenticatedPrincipal | ||
>>> from zope.app.security.principalregistry import UnauthenticatedPrincipal | ||
>>> anonymous = UnauthenticatedPrincipal('anon', '', '') | ||
>>> IUnauthenticatedPrincipal.providedBy(anonymous) | ||
True | ||
|
||
When LoginLogout is used for a request that has an unauthenticated principal, | ||
it provides the user with a link to 'Login': | ||
|
||
>>> from zope.publisher.browser import TestRequest | ||
>>> request = TestRequest() | ||
>>> request.setPrincipal(anonymous) | ||
>>> LoginLogout(None, request)() | ||
u'<a href="@@login.html?nextURL=http%3A//127.0.0.1">[Login]</a>' | ||
|
||
When LoginLogout is used for a request that has an authenticated principal: | ||
|
||
>>> from zope.security.interfaces import IPrincipal | ||
>>> from zope.interface import implements | ||
>>> class Bob: | ||
... implements(IPrincipal) | ||
... id = 'bob' | ||
... title = description = '' | ||
>>> bob = Bob() | ||
>>> IUnauthenticatedPrincipal.providedBy(bob) | ||
False | ||
>>> request.setPrincipal(bob) | ||
|
||
it provides the user with a link to 'Logout': | ||
|
||
>>> LoginLogout(None, request)() | ||
u'<a href="@@logout.html?nextURL=http%3A//127.0.0.1">[Logout]</a>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.