[Checkins] SVN: zope.app.security/trunk/ The PermissionsVocabulary and PermissionIdsVocabulary has been moved to zope.security as well as the registration of the "zope.Public" permission.
Dan Korostelev
nadako at gmail.com
Wed Mar 11 16:57:37 EDT 2009
Log message for revision 97914:
The PermissionsVocabulary and PermissionIdsVocabulary has been moved to zope.security as well as the registration of the "zope.Public" permission.
Changed:
_U zope.app.security/trunk/
U zope.app.security/trunk/CHANGES.txt
U zope.app.security/trunk/buildout.cfg
U zope.app.security/trunk/src/zope/app/security/configure.zcml
U zope.app.security/trunk/src/zope/app/security/tests/test_vocabulary.py
U zope.app.security/trunk/src/zope/app/security/vocabulary.py
-=-
Property changes on: zope.app.security/trunk
___________________________________________________________________
Modified: svn:ignore
- bin
build
dist
lib
develop-eggs
eggs
parts
.installed.cfg
+ bin
build
dist
lib
develop-eggs
eggs
parts
.installed.cfg
coverage
Modified: zope.app.security/trunk/CHANGES.txt
===================================================================
--- zope.app.security/trunk/CHANGES.txt 2009-03-11 20:54:42 UTC (rev 97913)
+++ zope.app.security/trunk/CHANGES.txt 2009-03-11 20:57:37 UTC (rev 97914)
@@ -5,6 +5,13 @@
3.7.0 (unreleased)
------------------
+- The PermissionsVocabulary and PermissionIdsVocabulary has been moved
+ to the ``zope.security`` package. Backward-compatibility imports are
+ provided.
+
+- The registration of the "zope.Public" permission has been moved to
+ ``zope.security``. Its configure.zcml is now included by this package.
+
- The ``LocalPermission`` class is now moved to new ``zope.localpermission``
package. This package now only has backward-compatibility imports and browser
views and menu items for ZMI.
Modified: zope.app.security/trunk/buildout.cfg
===================================================================
--- zope.app.security/trunk/buildout.cfg 2009-03-11 20:54:42 UTC (rev 97913)
+++ zope.app.security/trunk/buildout.cfg 2009-03-11 20:57:37 UTC (rev 97914)
@@ -1,7 +1,18 @@
[buildout]
-develop = . ../zope.localpermission
-parts = test
+develop = . ../zope.localpermission ../zope.security
+parts = test coverage-test coverage-report
[test]
recipe = zc.recipe.testrunner
eggs = zope.app.security [test]
+
+[coverage-test]
+recipe = zc.recipe.testrunner
+eggs = zope.app.security [test]
+defaults = ['--coverage', '../../coverage']
+
+[coverage-report]
+recipe = zc.recipe.egg
+eggs = z3c.coverage
+scripts = coverage=coverage-report
+arguments = ('coverage', 'coverage/report')
Modified: zope.app.security/trunk/src/zope/app/security/configure.zcml
===================================================================
--- zope.app.security/trunk/src/zope/app/security/configure.zcml 2009-03-11 20:54:42 UTC (rev 97913)
+++ zope.app.security/trunk/src/zope/app/security/configure.zcml 2009-03-11 20:57:37 UTC (rev 97914)
@@ -3,23 +3,9 @@
i18n_domain="zope"
>
- <permission
- id="zope.Public"
- title="[public-permission] Public"
- description="Special permission indicating unconditional access.
- Public resources are always accessible."
- />
+ <include package="zope.security" />
+ <include package="zope.localpermission" />
- <utility
- component=".vocabulary.PermissionsVocabulary"
- name="Permissions"
- />
-
- <utility
- component=".vocabulary.PermissionIdsVocabulary"
- name="Permission Ids"
- />
-
<include file="globalmodules.zcml" />
<include file="_protections.zcml" />
@@ -28,7 +14,6 @@
component=".principalregistry.principalRegistry"
/>
- <include package="zope.localpermission" />
<class class="zope.security.permission.Permission">
<allow
Modified: zope.app.security/trunk/src/zope/app/security/tests/test_vocabulary.py
===================================================================
--- zope.app.security/trunk/src/zope/app/security/tests/test_vocabulary.py 2009-03-11 20:54:42 UTC (rev 97913)
+++ zope.app.security/trunk/src/zope/app/security/tests/test_vocabulary.py 2009-03-11 20:57:37 UTC (rev 97914)
@@ -18,8 +18,23 @@
import unittest
from zope.testing.doctestunit import DocTestSuite
+def test_bbb_imports():
+ """
+ Let's check that permission vocabularies that were moved to
+ zope.security are still importable from original place.
+
+ >>> import zope.security.permission as new
+ >>> import zope.app.security.vocabulary as old
+ >>> old.PermissionsVocabulary is new.PermissionsVocabulary
+ True
+ >>> old.PermissionIdsVocabulary is new.PermissionIdsVocabulary
+ True
+
+ """
+
def test_suite():
return unittest.TestSuite((
+ DocTestSuite(),
DocTestSuite('zope.app.security.vocabulary'),
))
Modified: zope.app.security/trunk/src/zope/app/security/vocabulary.py
===================================================================
--- zope.app.security/trunk/src/zope/app/security/vocabulary.py 2009-03-11 20:54:42 UTC (rev 97913)
+++ zope.app.security/trunk/src/zope/app/security/vocabulary.py 2009-03-11 20:57:37 UTC (rev 97914)
@@ -20,99 +20,19 @@
__docformat__ = 'restructuredtext'
import zope.component
-from zope.interface import implements, classProvides
-from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary
-from zope.schema.interfaces import ISourceQueriables, IVocabularyFactory
-from zope.security.interfaces import IPermission
-from zope.security.checker import CheckerPublic
+from zope.interface import implements
+from zope.schema.interfaces import ISourceQueriables
from zope.site.next import queryNextUtility
from zope.app.security.interfaces import IAuthentication
from zope.app.security.interfaces import IPrincipalSource
from zope.app.security.interfaces import PrincipalLookupError
-from zope.app.component.vocabulary import UtilityVocabulary
+# BBB: these vocabularies are moved to zope.security.
+from zope.security.permission import PermissionsVocabulary
+from zope.security.permission import PermissionIdsVocabulary
-class PermissionsVocabulary(UtilityVocabulary):
- classProvides(IVocabularyFactory)
- interface = IPermission
-class PermissionIdsVocabulary(SimpleVocabulary):
- """A vocabular of permission IDs.
-
- Term values are the permission ID strings except for 'zope.Public', which
- is the global permission CheckerPublic.
-
- Term titles are the permission ID strings except for 'zope.Public', which
- is shortened to 'Public'.
-
- Terms are sorted by title except for 'Public', which always appears as
- the first term.
-
- To illustrate, we need to register the permission IDs vocab:
-
- >>> from zope.app.testing.placelesssetup import setUp, tearDown
- >>> setUp()
- >>> from zope.schema.vocabulary import getVocabularyRegistry
- >>> registry = getVocabularyRegistry()
- >>> registry.register('Permission Ids', PermissionIdsVocabulary)
-
- We also need to register some sample permission utilities, including
- the special permission 'zope.Public':
-
- >>> from zope.security.interfaces import IPermission
- >>> from zope.security.permission import Permission
- >>> from zope.app.testing import ztapi
- >>> ztapi.provideUtility(IPermission, Permission('zope.Public'),
- ... 'zope.Public')
- >>> ztapi.provideUtility(IPermission, Permission('b'), 'b')
- >>> ztapi.provideUtility(IPermission, Permission('a'), 'a')
-
- We can now lookup these permissions using the vocabulary:
-
- >>> vocab = registry.get(None, 'Permission Ids')
-
- The non-public permissions 'a' and 'b' are string values:
-
- >>> vocab.getTermByToken('a').value
- u'a'
- >>> vocab.getTermByToken('b').value
- u'b'
-
- However, the public permission value is CheckerPublic:
-
- >>> vocab.getTermByToken('zope.Public').value is CheckerPublic
- True
-
- and its title is shortened:
-
- >>> vocab.getTermByToken('zope.Public').title
- u'Public'
-
- The terms are sorted by title except for the public permission, which is
- listed first:
-
- >>> [term.title for term in vocab]
- [u'Public', u'a', u'b']
-
- >>> tearDown()
- """
- classProvides(IVocabularyFactory)
-
- def __init__(self, context):
- terms = []
- permissions = zope.component.getUtilitiesFor(IPermission, context)
- for name, permission in permissions:
- if name == 'zope.Public':
- terms.append(SimpleTerm(
- CheckerPublic, 'zope.Public', u'Public'))
- else:
- terms.append(SimpleTerm(name, name, name))
- terms.sort(lambda lhs, rhs: \
- lhs.title == u'Public' and -1 or cmp(lhs.title, rhs.title))
- super(PermissionIdsVocabulary, self).__init__(terms)
-
-
class PrincipalSource(object):
"""Generic Principal Source"""
implements(IPrincipalSource, ISourceQueriables)
More information about the Checkins
mailing list