[Checkins] SVN: zope.app.authentication/trunk/ Use the new ``zope.authentication`` package instead of ``zope.app.security``.

Dan Korostelev nadako at gmail.com
Thu Mar 12 09:32:49 EDT 2009


Log message for revision 97982:
  Use the new ``zope.authentication`` package instead of ``zope.app.security``. 
  
  Separate the presentation template and camefrom/redirection logic for the ``loginForm.html`` view.
  

Changed:
  U   zope.app.authentication/trunk/CHANGES.txt
  U   zope.app.authentication/trunk/buildout.cfg
  U   zope.app.authentication/trunk/setup.py
  U   zope.app.authentication/trunk/src/zope/app/authentication/README.txt
  U   zope.app.authentication/trunk/src/zope/app/authentication/authentication.py
  U   zope.app.authentication/trunk/src/zope/app/authentication/browser/groupfolder.txt
  U   zope.app.authentication/trunk/src/zope/app/authentication/browser/loginform.pt
  U   zope.app.authentication/trunk/src/zope/app/authentication/browser/register.py
  A   zope.app.authentication/trunk/src/zope/app/authentication/browser/session.py
  U   zope.app.authentication/trunk/src/zope/app/authentication/browser/session.zcml
  U   zope.app.authentication/trunk/src/zope/app/authentication/generic.py
  U   zope.app.authentication/trunk/src/zope/app/authentication/groupfolder.py
  U   zope.app.authentication/trunk/src/zope/app/authentication/groupfolder.txt
  U   zope.app.authentication/trunk/src/zope/app/authentication/interfaces.py
  U   zope.app.authentication/trunk/src/zope/app/authentication/principalfolder.py

-=-
Modified: zope.app.authentication/trunk/CHANGES.txt
===================================================================
--- zope.app.authentication/trunk/CHANGES.txt	2009-03-12 12:32:09 UTC (rev 97981)
+++ zope.app.authentication/trunk/CHANGES.txt	2009-03-12 13:32:48 UTC (rev 97982)
@@ -2,14 +2,21 @@
 Changes
 =======
 
-3.5.1 (unreleased)
+3.6.0 (unreleased)
 ------------------
 
-* Remove deprecated code.
+* Separate the presentation template and camefrom/redirection logic for the
+  ``loginForm.html`` view. Now the logic is contained in the
+  ``zope.app.authentication.browser.session.LoginForm`` class.
 
+* Use the new ``zope.authentication`` package instead of ``zope.app.security``. 
+
 * The "Password Manager Names" vocabulary and simple password manager registry
   were moved to the ``zope.password`` package.
 
+* Remove deprecated code.
+
+
 3.5.0 (2009-03-06)
 ------------------
 

Modified: zope.app.authentication/trunk/buildout.cfg
===================================================================
--- zope.app.authentication/trunk/buildout.cfg	2009-03-12 12:32:09 UTC (rev 97981)
+++ zope.app.authentication/trunk/buildout.cfg	2009-03-12 13:32:48 UTC (rev 97982)
@@ -1,5 +1,15 @@
 [buildout]
-develop = . ../zope.password
+develop =
+  .
+  ../zope.authentication
+  ../zope.component
+  ../zope.container
+  ../zope.password
+  ../zope.app.component
+  ../zope.app.container
+  ../zope.app.form
+  ../zope.app.publisher
+  ../zope.app.testing
 parts = test
 
 [test]

Modified: zope.app.authentication/trunk/setup.py
===================================================================
--- zope.app.authentication/trunk/setup.py	2009-03-12 12:32:09 UTC (rev 97981)
+++ zope.app.authentication/trunk/setup.py	2009-03-12 13:32:48 UTC (rev 97982)
@@ -22,7 +22,7 @@
     return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
 
 setup(name='zope.app.authentication',
-      version = '3.5.1dev',
+      version = '3.6.0dev',
       author='Zope Corporation and Contributors',
       author_email='zope-dev at zope.org',
       description='Pluggable Authentication Utility',
@@ -65,7 +65,7 @@
                         'zope.app.component',
                         'zope.app.container',
                         'zope.app.form',
-                        'zope.app.security',
+                        'zope.authentication',
                         'zope.dublincore',
                         'zope.event',
                         'zope.exceptions',

Modified: zope.app.authentication/trunk/src/zope/app/authentication/README.txt
===================================================================
--- zope.app.authentication/trunk/src/zope/app/authentication/README.txt	2009-03-12 12:32:09 UTC (rev 97981)
+++ zope.app.authentication/trunk/src/zope/app/authentication/README.txt	2009-03-12 13:32:48 UTC (rev 97982)
@@ -8,7 +8,7 @@
 
 For a pluggable-authentication utility to be used, it should be
 registered as a utility providing the
-`zope.app.security.interfaces.IAuthentication` interface.
+`zope.authentication.interfaces.IAuthentication` interface.
 
 Authentication
 --------------

Modified: zope.app.authentication/trunk/src/zope/app/authentication/authentication.py
===================================================================
--- zope.app.authentication/trunk/src/zope/app/authentication/authentication.py	2009-03-12 12:32:09 UTC (rev 97981)
+++ zope.app.authentication/trunk/src/zope/app/authentication/authentication.py	2009-03-12 13:32:48 UTC (rev 97982)
@@ -21,7 +21,7 @@
 from zope.location.interfaces import ILocation
 from zope.site.next import queryNextUtility
 
-from zope.app.security.interfaces import IAuthentication, PrincipalLookupError
+from zope.authentication.interfaces import IAuthentication, PrincipalLookupError
 import zope.container.btree
 
 from zope.app.authentication import interfaces

Modified: zope.app.authentication/trunk/src/zope/app/authentication/browser/groupfolder.txt
===================================================================
--- zope.app.authentication/trunk/src/zope/app/authentication/browser/groupfolder.txt	2009-03-12 12:32:09 UTC (rev 97981)
+++ zope.app.authentication/trunk/src/zope/app/authentication/browser/groupfolder.txt	2009-03-12 13:32:48 UTC (rev 97982)
@@ -639,8 +639,8 @@
 
 and we'll get the pluggable authentication utility:
 
+  >>> from zope.authentication.interfaces import IAuthentication
   >>> from zope.component import getUtility
-  >>> from zope.app.security.interfaces import IAuthentication
   >>> principals = getUtility(IAuthentication)
 
 Finally we'll get Betty and see that she is in the admin and

Modified: zope.app.authentication/trunk/src/zope/app/authentication/browser/loginform.pt
===================================================================
--- zope.app.authentication/trunk/src/zope/app/authentication/browser/loginform.pt	2009-03-12 12:32:09 UTC (rev 97981)
+++ zope.app.authentication/trunk/src/zope/app/authentication/browser/loginform.pt	2009-03-12 13:32:48 UTC (rev 97982)
@@ -1,40 +1,46 @@
-<html metal:use-macro="context/@@standard_macros/page"
-    i18n:domain="zope">
+<html metal:use-macro="context/@@standard_macros/page" i18n:domain="zope">
 <head>
-  <title metal:fill-slot="title" i18n:translate="">
-    Sign in
-  </title>
+  <title metal:fill-slot="title" i18n:translate="">Sign in</title>
 </head>
-<body><div metal:fill-slot="body" tal:define="principal python:request.principal.id">
-    <p i18n:translate="" tal:condition="python: principal == 'zope.anybody'">
-      Please provide Login Information</p>
-    <p i18n:translate="" tal:condition="python: principal != 'zope.anybody'">
+<body>
+  <div metal:fill-slot="body">
+
+    <p i18n:translate="" tal:condition="view/unauthenticated">
+      Please provide Login Information
+    </p>
+
+    <p i18n:translate="" 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>
+      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">
-                <input type="text" name="login" id="login" />
-            </div>
-        </div>
 
-        <div class="row">
-            <div class="label"><label for="password" i18n:translate="">Password</label></div>
-            <div class="field">
-                <input type="password" name="password" id="password" />
-            </div>
+      <div class="row">
+        <div class="label"><label for="login" i18n:translate="">User Name</label></div>
+          <div class="field">
+            <input type="text" name="login" id="login" />
+          </div>
+      </div>
+
+      <div class="row">
+        <div class="label"><label for="password" i18n:translate="">Password</label></div>
+        <div class="field">
+          <input type="password" name="password" id="password" />
         </div>
+      </div>
     
-        <div class="row">
-            <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">
+      <div class="row">
+        <input class="form-element" type="submit" 
+               name="SUBMIT" value="Log in" i18n:attributes="value login-button" />
+      </div>
+
+      <input type="hidden" name="camefrom"
+             tal:condition="view/camefrom" 
+             tal:attributes="value view/camefrom" />
+
     </form>
-</div></body></html>
 
+  </div>
+</body>
+</html>

Modified: zope.app.authentication/trunk/src/zope/app/authentication/browser/register.py
===================================================================
--- zope.app.authentication/trunk/src/zope/app/authentication/browser/register.py	2009-03-12 12:32:09 UTC (rev 97981)
+++ zope.app.authentication/trunk/src/zope/app/authentication/browser/register.py	2009-03-12 13:32:48 UTC (rev 97982)
@@ -18,11 +18,11 @@
 
 from zope.app.authentication.i18n import ZopeMessageFactory as _
 import zope.app.component.browser.registration
-import zope.app.security.interfaces
+import zope.authentication.interfaces
 
 class AddAuthenticationRegistration(
     zope.app.component.browser.registration.AddUtilityRegistration,
     ):
     label = _("Register a pluggable authentication utility")
     name = ''
-    provided = zope.app.security.interfaces.IAuthentication
+    provided = zope.authentication.interfaces.IAuthentication

Added: zope.app.authentication/trunk/src/zope/app/authentication/browser/session.py
===================================================================
--- zope.app.authentication/trunk/src/zope/app/authentication/browser/session.py	                        (rev 0)
+++ zope.app.authentication/trunk/src/zope/app/authentication/browser/session.py	2009-03-12 13:32:48 UTC (rev 97982)
@@ -0,0 +1,42 @@
+##############################################################################
+#
+# 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 LoginForm(object):
+    """Mix-in class to implement login form logic"""
+    
+    def __call__(self):
+        request = self.request
+        principal = request.principal
+
+        unauthenticated = IUnauthenticatedPrincipal.providedBy(principal)
+        self.unauthenticated = unauthenticated
+        
+        camefrom = 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
+        
+        if ('SUBMIT' in request) and not unauthenticated:
+            # authenticated by submitting
+            request.response.redirect(camefrom or '.')
+            return ''
+        
+        return self.index() # call template


Property changes on: zope.app.authentication/trunk/src/zope/app/authentication/browser/session.py
___________________________________________________________________
Added: svn:keywords
   + Id,svn:eol-style=native

Modified: zope.app.authentication/trunk/src/zope/app/authentication/browser/session.zcml
===================================================================
--- zope.app.authentication/trunk/src/zope/app/authentication/browser/session.zcml	2009-03-12 12:32:09 UTC (rev 97981)
+++ zope.app.authentication/trunk/src/zope/app/authentication/browser/session.zcml	2009-03-12 13:32:48 UTC (rev 97982)
@@ -20,6 +20,7 @@
       name="loginForm.html" 
       for="*"
       template="loginform.pt"
+      class=".session.LoginForm"
       permission="zope.Public" 
       />
 

Modified: zope.app.authentication/trunk/src/zope/app/authentication/generic.py
===================================================================
--- zope.app.authentication/trunk/src/zope/app/authentication/generic.py	2009-03-12 12:32:09 UTC (rev 97981)
+++ zope.app.authentication/trunk/src/zope/app/authentication/generic.py	2009-03-12 13:32:48 UTC (rev 97982)
@@ -17,9 +17,8 @@
 """
 __docformat__ = "reStructuredText"
 from zope.interface import implements
+from zope.authentication.interfaces import IUnauthenticatedPrincipal
 
-from zope.app.security.interfaces import IUnauthenticatedPrincipal
-
 from zope.app.authentication import interfaces
 
 

Modified: zope.app.authentication/trunk/src/zope/app/authentication/groupfolder.py
===================================================================
--- zope.app.authentication/trunk/src/zope/app/authentication/groupfolder.py	2009-03-12 12:32:09 UTC (rev 97981)
+++ zope.app.authentication/trunk/src/zope/app/authentication/groupfolder.py	2009-03-12 13:32:48 UTC (rev 97982)
@@ -28,8 +28,8 @@
 import zope.container.constraints
 import zope.container.interfaces
 from zope.app.authentication.i18n import ZopeMessageFactory as _
-import zope.app.security.vocabulary
-from zope.app.security.interfaces import (
+import zope.authentication.principal
+from zope.authentication.interfaces import (
     IAuthentication, IAuthenticatedGroup, IEveryoneGroup)
 from zope.app.authentication import principalfolder, interfaces
 
@@ -49,7 +49,7 @@
     principals = schema.List(
         title=_("Principals"),
         value_type=schema.Choice(
-            source=zope.app.security.vocabulary.PrincipalSource()),
+            source=zope.authentication.principal.PrincipalSource()),
         description=_(
         "List of ids of principals which belong to the group"),
         required=False)

Modified: zope.app.authentication/trunk/src/zope/app/authentication/groupfolder.txt
===================================================================
--- zope.app.authentication/trunk/src/zope/app/authentication/groupfolder.txt	2009-03-12 12:32:09 UTC (rev 97981)
+++ zope.app.authentication/trunk/src/zope/app/authentication/groupfolder.txt	2009-03-12 13:32:48 UTC (rev 97982)
@@ -31,8 +31,8 @@
 we'll create a sample authentication service:
 
   >>> from zope import interface
-  >>> from zope.app.security.interfaces import IAuthentication
-  >>> from zope.app.security.interfaces import PrincipalLookupError
+  >>> from zope.authentication.interfaces import IAuthentication
+  >>> from zope.authentication.interfaces import PrincipalLookupError
   >>> from zope.security.interfaces import IGroupAwarePrincipal
   >>> from zope.app.authentication.groupfolder import setGroupsForPrincipal
 
@@ -295,12 +295,12 @@
 
 Now, if we define the Everybody group:
 
-  >>> import zope.app.security.interfaces
+  >>> import zope.authentication.interfaces
   >>> class EverybodyGroup(Principal):
-  ...     interface.implements(zope.app.security.interfaces.IEveryoneGroup)
+  ...     interface.implements(zope.authentication.interfaces.IEveryoneGroup)
 
   >>> everybody = EverybodyGroup('all')
-  >>> ztapi.provideUtility(zope.app.security.interfaces.IEveryoneGroup,
+  >>> ztapi.provideUtility(zope.authentication.interfaces.IEveryoneGroup,
   ...                      everybody)
 
 Then the group will be added to the principal:
@@ -313,10 +313,10 @@
 
   >>> class AuthenticatedGroup(Principal):
   ...     interface.implements(
-  ...         zope.app.security.interfaces.IAuthenticatedGroup)
+  ...         zope.authentication.interfaces.IAuthenticatedGroup)
 
   >>> authenticated = AuthenticatedGroup('auth')
-  >>> ztapi.provideUtility(zope.app.security.interfaces.IAuthenticatedGroup,
+  >>> ztapi.provideUtility(zope.authentication.interfaces.IAuthenticatedGroup,
   ...                      authenticated)
 
 Then the group will be added to the principal:

Modified: zope.app.authentication/trunk/src/zope/app/authentication/interfaces.py
===================================================================
--- zope.app.authentication/trunk/src/zope/app/authentication/interfaces.py	2009-03-12 12:32:09 UTC (rev 97981)
+++ zope.app.authentication/trunk/src/zope/app/authentication/interfaces.py	2009-03-12 13:32:48 UTC (rev 97982)
@@ -21,7 +21,7 @@
 import zope.schema
 import zope.security.interfaces
 from zope.app.authentication.i18n import ZopeMessageFactory as _
-from zope.app.security.interfaces import ILogout
+from zope.authentication.interfaces import ILogout
 from zope.container.constraints import contains, containers
 from zope.container.interfaces import IContainer
 
@@ -36,7 +36,7 @@
     """Provides authentication services with the help of various plugins.
     
     IPluggableAuthentication implementations will also implement
-    zope.app.security.interfaces.IAuthentication.  The `authenticate` method
+    zope.authentication.interfaces.IAuthentication.  The `authenticate` method
     of this interface in an IPluggableAuthentication should annotate the
     IPrincipalInfo with the credentials plugin and authentication plugin used.
     The `getPrincipal` method should annotate the IPrincipalInfo with the

Modified: zope.app.authentication/trunk/src/zope/app/authentication/principalfolder.py
===================================================================
--- zope.app.authentication/trunk/src/zope/app/authentication/principalfolder.py	2009-03-12 12:32:09 UTC (rev 97981)
+++ zope.app.authentication/trunk/src/zope/app/authentication/principalfolder.py	2009-03-12 13:32:48 UTC (rev 97982)
@@ -24,13 +24,13 @@
 from zope.schema import Text, TextLine, Password, Choice
 from zope.publisher.interfaces import IRequest
 
+from zope.authentication.interfaces import IAuthentication
 from zope.container.interfaces import DuplicateIDError
 from zope.container.contained import Contained
 from zope.container.constraints import contains, containers
 from zope.container.btree import BTreeContainer
 from zope.password.interfaces import IPasswordManager
 from zope.app.authentication.i18n import ZopeMessageFactory as _
-from zope.app.security.interfaces import IAuthentication
 
 from zope.app.authentication import interfaces
 



More information about the Checkins mailing list