[Checkins] SVN: z3c.authviewlet/trunk/ - Moved code from page template of session credentials login page to view class so it can be customized. (Taken from `zope.app.authentication.browser.loginform.LoginForm`.) Moved view class ``SessionCredentialsLoginForm`` from `z3c.authviewlet.auth` to `z3c.authviewlet.session`.
Michael Howitz
mh at gocept.com
Wed Oct 13 11:06:28 EDT 2010
Log message for revision 117515:
- Moved code from page template of session credentials login page to view class so it can be customized. (Taken from `zope.app.authentication.browser.loginform.LoginForm`.) Moved view class ``SessionCredentialsLoginForm`` from `z3c.authviewlet.auth` to `z3c.authviewlet.session`.
Changed:
U z3c.authviewlet/trunk/CHANGES.txt
U z3c.authviewlet/trunk/src/z3c/authviewlet/auth.py
U z3c.authviewlet/trunk/src/z3c/authviewlet/configure.zcml
A z3c.authviewlet/trunk/src/z3c/authviewlet/session.py
U z3c.authviewlet/trunk/src/z3c/authviewlet/session_cred_loginform.pt
-=-
Modified: z3c.authviewlet/trunk/CHANGES.txt
===================================================================
--- z3c.authviewlet/trunk/CHANGES.txt 2010-10-13 13:41:25 UTC (rev 117514)
+++ z3c.authviewlet/trunk/CHANGES.txt 2010-10-13 15:06:27 UTC (rev 117515)
@@ -7,6 +7,11 @@
- Adapted test set up to the changes in `z3c.layer.pagelet` 1.9 thus
requiring at least this version now.
+- Moved code from page template of session credentials login page to view
+ class so it can be customized. (Taken from
+ `zope.app.authentication.browser.loginform.LoginForm`.) Moved view class
+ ``SessionCredentialsLoginForm`` from `z3c.authviewlet.auth` to
+ `z3c.authviewlet.session`.
0.7.0 (2009-12-27)
~~~~~~~~~~~~~~~~~~
@@ -17,7 +22,6 @@
- Broke dependency on `zope.app.publisher` by defining our own
``ILogin`` interface.
-
0.6.0 (2009-12-24)
~~~~~~~~~~~~~~~~~~
Modified: z3c.authviewlet/trunk/src/z3c/authviewlet/auth.py
===================================================================
--- z3c.authviewlet/trunk/src/z3c/authviewlet/auth.py 2010-10-13 13:41:25 UTC (rev 117514)
+++ z3c.authviewlet/trunk/src/z3c/authviewlet/auth.py 2010-10-13 15:06:27 UTC (rev 117515)
@@ -168,7 +168,3 @@
"Pagelet to display logout success."
-class SessionCredentialsLoginForm(object):
- "Login form using session credentials."
-
-
Modified: z3c.authviewlet/trunk/src/z3c/authviewlet/configure.zcml
===================================================================
--- z3c.authviewlet/trunk/src/z3c/authviewlet/configure.zcml 2010-10-13 13:41:25 UTC (rev 117514)
+++ z3c.authviewlet/trunk/src/z3c/authviewlet/configure.zcml 2010-10-13 15:06:27 UTC (rev 117515)
@@ -59,12 +59,12 @@
for="*"
layer="z3c.layer.pagelet.IPageletBrowserLayer"
name="loginForm.html"
- class=".auth.SessionCredentialsLoginForm"
+ class=".session.SessionCredentialsLoginForm"
permission="zope.Public"
/>
<z3c:template
- for=".auth.SessionCredentialsLoginForm"
+ for=".session.SessionCredentialsLoginForm"
layer="z3c.layer.pagelet.IPageletBrowserLayer"
template="session_cred_loginform.pt"
/>
Copied: z3c.authviewlet/trunk/src/z3c/authviewlet/session.py (from rev 117514, zope.app.authentication/trunk/src/zope/app/authentication/browser/loginform.py)
===================================================================
--- z3c.authviewlet/trunk/src/z3c/authviewlet/session.py (rev 0)
+++ z3c.authviewlet/trunk/src/z3c/authviewlet/session.py 2010-10-13 15:06:27 UTC (rev 117515)
@@ -0,0 +1,39 @@
+##############################################################################
+#
+# Copyright (c) 2009 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Login Form
+
+$Id$
+"""
+from zope.authentication.interfaces import IUnauthenticatedPrincipal
+
+class SessionCredentialsLoginForm(object):
+ "Login form using session credentials."
+
+ def __init__(self, *args):
+ super(SessionCredentialsLoginForm, self).__init__(*args)
+ self.unauthenticated = IUnauthenticatedPrincipal.providedBy(
+ self.request.principal)
+
+ camefrom = self.request.get('camefrom')
+ if isinstance(camefrom, list):
+ # this can happen on python2.6, as it changed the
+ # behaviour of cgi.FieldStorage a bit.
+ camefrom = camefrom[0]
+ self.camefrom = camefrom
+
+ def update(self):
+ """Redirect when authenticated."""
+ if (not self.unauthenticated) and ('SUBMIT' in self.request):
+ # authenticated by submitting
+ self.request.response.redirect(self.camefrom or '.')
Modified: z3c.authviewlet/trunk/src/z3c/authviewlet/session_cred_loginform.pt
===================================================================
--- z3c.authviewlet/trunk/src/z3c/authviewlet/session_cred_loginform.pt 2010-10-13 13:41:25 UTC (rev 117514)
+++ z3c.authviewlet/trunk/src/z3c/authviewlet/session_cred_loginform.pt 2010-10-13 15:06:27 UTC (rev 117515)
@@ -1,19 +1,14 @@
-<div i18n:domain="z3c"
- tal:define="principal python:request.principal.id">
+<div i18n:domain="z3c">
<p i18n:translate=""
- tal:condition="python: principal == 'zope.anybody'">
+ tal:condition="view/unauthenticated">
Please provide Login Information
</p>
<p i18n:translate=""
- tal:condition="python: principal != 'zope.anybody'">
+ tal:condition="not:view/unauthenticated">
You are not authorized to perform this action. However, you may login as a
different user who is authorized.
</p>
<form action="" method="post">
- <div tal:omit-tag=""
- tal:condition="python:principal != 'zope.anybody' and 'SUBMIT' in request">
- <span tal:define="dummy python:request.response.redirect(request.get('camefrom', ''))" />
- </div>
<div class="row">
<div class="label"><label for="login" i18n:translate="">User Name</label></div>
<div class="field">
@@ -32,6 +27,6 @@
<input class="form-element" type="submit"
name="SUBMIT" value="Log in" i18n:attributes="value login-button" />
</div>
- <input type="hidden" name="camefrom" tal:attributes="value request/camefrom | nothing">
+ <input type="hidden" name="camefrom" tal:attributes="value view/camefrom">
</form>
</div>
More information about the checkins
mailing list