[Checkins] SVN: zope. Move password manager names vocabulary to zope.password again, now specifying an "extra" dependency (see mailing list discussion about that).
Dan Korostelev
nadako at gmail.com
Wed Mar 11 03:59:29 EDT 2009
Log message for revision 97822:
Move password manager names vocabulary to zope.password again, now specifying an "extra" dependency (see mailing list discussion about that).
Also move the simple "managers" registry to zope.password.
Changed:
U zope.app.authentication/trunk/CHANGES.txt
U zope.app.authentication/trunk/buildout.cfg
U zope.app.authentication/trunk/src/zope/app/authentication/password.py
U zope.app.authentication/trunk/src/zope/app/authentication/password.zcml
U zope.password/trunk/CHANGES.txt
U zope.password/trunk/README.txt
U zope.password/trunk/setup.py
U zope.password/trunk/src/zope/password/configure.zcml
U zope.password/trunk/src/zope/password/password.py
U zope.password/trunk/src/zope/password/testing.py
A zope.password/trunk/src/zope/password/vocabulary.py
-=-
Modified: zope.app.authentication/trunk/CHANGES.txt
===================================================================
--- zope.app.authentication/trunk/CHANGES.txt 2009-03-11 07:52:40 UTC (rev 97821)
+++ zope.app.authentication/trunk/CHANGES.txt 2009-03-11 07:59:29 UTC (rev 97822)
@@ -7,6 +7,9 @@
* Remove deprecated code.
+* The "Password Manager Names" vocabulary and simple password manager registry
+ were moved to the ``zope.password`` package.
+
3.5.0 (2009-03-06)
------------------
Modified: zope.app.authentication/trunk/buildout.cfg
===================================================================
--- zope.app.authentication/trunk/buildout.cfg 2009-03-11 07:52:40 UTC (rev 97821)
+++ zope.app.authentication/trunk/buildout.cfg 2009-03-11 07:59:29 UTC (rev 97822)
@@ -1,5 +1,5 @@
[buildout]
-develop = .
+develop = . ../zope.password
parts = test
[test]
Modified: zope.app.authentication/trunk/src/zope/app/authentication/password.py
===================================================================
--- zope.app.authentication/trunk/src/zope/app/authentication/password.py 2009-03-11 07:52:40 UTC (rev 97821)
+++ zope.app.authentication/trunk/src/zope/app/authentication/password.py 2009-03-11 07:59:29 UTC (rev 97822)
@@ -11,34 +11,18 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Password managers
+"""Backward compatibility imports for password managers
$Id$
"""
__docformat__ = 'restructuredtext'
-from zope.app.component.vocabulary import UtilityVocabulary
-
# BBB: the password managers were moved into zope.password package.
from zope.password.password import (
PlainTextPasswordManager,
MD5PasswordManager,
SHA1PasswordManager,
- SSHAPasswordManager
+ SSHAPasswordManager,
+ managers,
)
-from zope.password.interfaces import IPasswordManager
-
-# Simple registry used by mkzopeinstance script
-managers = [
- ("Plain Text", PlainTextPasswordManager()), # default
- ("MD5", MD5PasswordManager()),
- ("SHA1", SHA1PasswordManager()),
- ("SSHA", SSHAPasswordManager()),
-]
-
-
-class PasswordManagerNamesVocabulary(UtilityVocabulary):
- """Vocabulary of password managers."""
-
- interface = IPasswordManager
- nameOnly = True
+from zope.password.vocabulary import PasswordManagerNamesVocabulary
Modified: zope.app.authentication/trunk/src/zope/app/authentication/password.zcml
===================================================================
--- zope.app.authentication/trunk/src/zope/app/authentication/password.zcml 2009-03-11 07:52:40 UTC (rev 97821)
+++ zope.app.authentication/trunk/src/zope/app/authentication/password.zcml 2009-03-11 07:59:29 UTC (rev 97822)
@@ -2,10 +2,4 @@
<include package="zope.password" />
- <utility
- component=".password.PasswordManagerNamesVocabulary"
- provides="zope.schema.interfaces.IVocabularyFactory"
- name="Password Manager Names"
- />
-
</configure>
Modified: zope.password/trunk/CHANGES.txt
===================================================================
--- zope.password/trunk/CHANGES.txt 2009-03-11 07:52:40 UTC (rev 97821)
+++ zope.password/trunk/CHANGES.txt 2009-03-11 07:59:29 UTC (rev 97822)
@@ -5,8 +5,17 @@
3.5.1 (unreleased)
------------------
-- ...
+- Make security protection directives in `configure.zcml` execute only
+ if ``zope.security`` is installed. This will allow reuse of the
+ `configure.zcml` file in environments without ``zope.security``,
+ for example with ``repoze.zcml``.
+- Add "Password Manager Names" vocabulary for use with ``zope.schema``
+ and ``zope.component``, like it was in ``zope.app.authentication``. It's
+ an optional feature so it doesn't add hard dependency. We use "vocabulary"
+ extra to list dependencies needed for vocabulary functionality. Also, the
+ zcml vocabulary registration is executed only if ``zope.schema`` is installed.
+
3.5.0 (2009-03-06)
------------------
Modified: zope.password/trunk/README.txt
===================================================================
--- zope.password/trunk/README.txt 2009-03-11 07:52:40 UTC (rev 97821)
+++ zope.password/trunk/README.txt 2009-03-11 07:59:29 UTC (rev 97822)
@@ -25,6 +25,7 @@
It is strongly recommended to use SSHAPasswordManager, as it's the most secure.
+
Usage
-----
@@ -38,3 +39,17 @@
"""Return whether the given encoded data coincide with the given password"""
The implementations mentioned above are in the ``zope.password.password`` module.
+
+
+Password Manager Names Vocabulary
+---------------------------------
+
+The ``zope.password.vocabulary`` module provides a vocabulary of registered
+password manager utility names. It is typically registered as an
+`IVocabularyFactory` utility named "Password Manager Names".
+
+It's intended to be used with ``zope.component`` and ``zope.schema``, so
+you need to have them installed and the utility registrations needs to
+be done properly. The `configure.zcml` file, contained in ``zope.password``
+does the registrations, as well as in `setUpPasswordManagers` function in
+``zope.password.testing`` module.
Modified: zope.password/trunk/setup.py
===================================================================
--- zope.password/trunk/setup.py 2009-03-11 07:52:40 UTC (rev 97821)
+++ zope.password/trunk/setup.py 2009-03-11 07:59:29 UTC (rev 97822)
@@ -43,7 +43,9 @@
keywords='zope3 zope authentication password',
packages=find_packages('src'),
package_dir = {'': 'src'},
- extras_require=dict(test=['zope.testing', 'zope.component']),
+ extras_require=dict(vocabulary=['zope.component', 'zope.schema'],
+ test=['zope.testing', 'zope.component', 'zope.schema'],
+ ),
namespace_packages=['zope'],
install_requires=['setuptools',
'zope.interface',
Modified: zope.password/trunk/src/zope/password/configure.zcml
===================================================================
--- zope.password/trunk/src/zope/password/configure.zcml 2009-03-11 07:52:40 UTC (rev 97821)
+++ zope.password/trunk/src/zope/password/configure.zcml 2009-03-11 07:59:29 UTC (rev 97822)
@@ -1,43 +1,57 @@
-<configure xmlns="http://namespaces.zope.org/zope">
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:zcml="http://namespaces.zope.org/zcml"
+ >
- <class class=".password.PlainTextPasswordManager">
- <allow interface=".interfaces.IPasswordManager" />
- </class>
-
<utility
name="Plain Text"
provides=".interfaces.IPasswordManager"
factory=".password.PlainTextPasswordManager"
/>
- <class class=".password.MD5PasswordManager">
- <allow interface=".interfaces.IPasswordManager" />
- </class>
-
<utility
name="MD5"
provides=".interfaces.IPasswordManager"
factory=".password.MD5PasswordManager"
/>
- <class class=".password.SHA1PasswordManager">
- <allow interface=".interfaces.IPasswordManager" />
- </class>
-
<utility
name="SHA1"
provides=".interfaces.IPasswordManager"
factory=".password.SHA1PasswordManager"
/>
- <class class=".password.SSHAPasswordManager">
- <allow interface=".interfaces.IPasswordManager" />
- </class>
-
<utility
name="SSHA"
provides=".interfaces.IPasswordManager"
factory=".password.SSHAPasswordManager"
/>
+ <utility
+ zcml:condition="installed zope.schema"
+ component=".vocabulary.PasswordManagerNamesVocabulary"
+ provides="zope.schema.interfaces.IVocabularyFactory"
+ name="Password Manager Names"
+ />
+
+ <configure zcml:condition="installed zope.security">
+
+ <class class=".password.PlainTextPasswordManager">
+ <allow interface=".interfaces.IPasswordManager" />
+ </class>
+
+ <class class=".password.MD5PasswordManager">
+ <allow interface=".interfaces.IPasswordManager" />
+ </class>
+
+ <class class=".password.SHA1PasswordManager">
+ <allow interface=".interfaces.IPasswordManager" />
+ </class>
+
+ <class class=".password.SSHAPasswordManager">
+ <allow interface=".interfaces.IPasswordManager" />
+ </class>
+
+ </configure>
+
</configure>
Modified: zope.password/trunk/src/zope/password/password.py
===================================================================
--- zope.password/trunk/src/zope/password/password.py 2009-03-11 07:52:40 UTC (rev 97821)
+++ zope.password/trunk/src/zope/password/password.py 2009-03-11 07:59:29 UTC (rev 97822)
@@ -246,3 +246,12 @@
return encoded_password == self.encodePassword(password, salt)
salt = encoded_password[:-40]
return encoded_password == self.encodePassword(password, salt)[6:]
+
+
+# Simple registry
+managers = [
+ ('Plain Text', PlainTextPasswordManager()),
+ ('MD5', MD5PasswordManager()),
+ ('SHA1', SHA1PasswordManager()),
+ ('SSHA', SSHAPasswordManager()),
+]
Modified: zope.password/trunk/src/zope/password/testing.py
===================================================================
--- zope.password/trunk/src/zope/password/testing.py 2009-03-11 07:52:40 UTC (rev 97821)
+++ zope.password/trunk/src/zope/password/testing.py 2009-03-11 07:59:29 UTC (rev 97822)
@@ -16,12 +16,16 @@
$Id$
"""
__docformat__ = "reStructuredText"
+
from zope.component import provideUtility
+from zope.schema.interfaces import IVocabularyFactory
+
from zope.password.interfaces import IPasswordManager
from zope.password.password import PlainTextPasswordManager
from zope.password.password import MD5PasswordManager
from zope.password.password import SHA1PasswordManager
from zope.password.password import SSHAPasswordManager
+from zope.password.vocabulary import PasswordManagerNamesVocabulary
def setUpPasswordManagers():
@@ -29,6 +33,7 @@
>>> from zope.component import getUtility
>>> setUpPasswordManagers()
+
>>> getUtility(IPasswordManager, 'Plain Text')
<zope.password.password.PlainTextPasswordManager object at 0x...>
>>> getUtility(IPasswordManager, 'SSHA')
@@ -37,9 +42,25 @@
<zope.password.password.MD5PasswordManager object at 0x...>
>>> getUtility(IPasswordManager, 'SHA1')
<zope.password.password.SHA1PasswordManager object at 0x...>
+
+ >>> voc = getUtility(IVocabularyFactory, 'Password Manager Names')
+ >>> voc = voc(None)
+ >>> voc
+ <zope.schema.vocabulary.SimpleVocabulary object at 0x...>
+ >>> 'SSHA' in voc
+ True
+ >>> 'Plain Text' in voc
+ True
+ >>> 'SHA1' in voc
+ True
+ >>> 'MD5' in voc
+ True
"""
provideUtility(PlainTextPasswordManager(), IPasswordManager, 'Plain Text')
provideUtility(SSHAPasswordManager(), IPasswordManager, 'SSHA')
provideUtility(MD5PasswordManager(), IPasswordManager, 'MD5')
provideUtility(SHA1PasswordManager(), IPasswordManager, 'SHA1')
+
+ provideUtility(PasswordManagerNamesVocabulary,
+ IVocabularyFactory, 'Password Manager Names')
Copied: zope.password/trunk/src/zope/password/vocabulary.py (from rev 97794, zope.password/trunk/src/zope/password/vocabulary.py)
===================================================================
--- zope.password/trunk/src/zope/password/vocabulary.py (rev 0)
+++ zope.password/trunk/src/zope/password/vocabulary.py 2009-03-11 07:59:29 UTC (rev 97822)
@@ -0,0 +1,32 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Vocabulary of password manager utility names for use with zope.component and
+zope.schema.
+
+$Id$
+"""
+from zope.component import getUtilitiesFor
+from zope.interface import directlyProvides
+from zope.schema.interfaces import IVocabularyFactory
+from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
+
+from zope.password.interfaces import IPasswordManager
+
+def PasswordManagerNamesVocabulary(context=None):
+ terms = []
+ for name, util in getUtilitiesFor(IPasswordManager, context):
+ terms.append(SimpleTerm(name))
+ return SimpleVocabulary(terms)
+
+directlyProvides(PasswordManagerNamesVocabulary, IVocabularyFactory)
More information about the Checkins
mailing list