[Zope3-checkins] SVN: Zope3/trunk/ expose the Allow/Deny/Unset constants through

Fred L. Drake, Jr. fdrake at gmail.com
Tue Sep 19 12:31:48 EDT 2006


Log message for revision 70228:
  expose the Allow/Deny/Unset constants through
  zope.app.securitypolicy.interfaces, and make that the preferred import
  source for those values
  (see also http://www.zope.org/Collectors/Zope3-dev/712)
  

Changed:
  U   Zope3/trunk/doc/CHANGES.txt
  U   Zope3/trunk/src/zope/app/securitypolicy/browser/granting.py
  U   Zope3/trunk/src/zope/app/securitypolicy/browser/granting.txt
  U   Zope3/trunk/src/zope/app/securitypolicy/browser/rolepermissionview.py
  U   Zope3/trunk/src/zope/app/securitypolicy/browser/tests/rolepermissionmanager.py
  U   Zope3/trunk/src/zope/app/securitypolicy/grantinfo.py
  U   Zope3/trunk/src/zope/app/securitypolicy/interfaces.py
  U   Zope3/trunk/src/zope/app/securitypolicy/principalpermission.py
  U   Zope3/trunk/src/zope/app/securitypolicy/principalrole.py
  U   Zope3/trunk/src/zope/app/securitypolicy/rolepermission.py
  U   Zope3/trunk/src/zope/app/securitypolicy/tests/test_annotationprincipalpermissionmanager.py
  U   Zope3/trunk/src/zope/app/securitypolicy/tests/test_annotationprincipalrolemanager.py
  U   Zope3/trunk/src/zope/app/securitypolicy/tests/test_annotationrolepermissionmanager.py
  U   Zope3/trunk/src/zope/app/securitypolicy/tests/test_principalpermissionmanager.py
  U   Zope3/trunk/src/zope/app/securitypolicy/tests/test_principalrolemanager.py
  U   Zope3/trunk/src/zope/app/securitypolicy/tests/test_rolepermissionmanager.py
  U   Zope3/trunk/src/zope/app/securitypolicy/tests/test_securitydirectives.py
  U   Zope3/trunk/src/zope/app/securitypolicy/zopepolicy.py

-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt	2006-09-19 15:40:46 UTC (rev 70227)
+++ Zope3/trunk/doc/CHANGES.txt	2006-09-19 16:31:47 UTC (rev 70228)
@@ -10,6 +10,12 @@
 
     New features
 
+      - The security setting values from zope.app.security.settings are now
+        exported by zope.app.securitypolicy.interfaces, since they are
+        exposed by the APIs defined there, and are not used in the
+        zope.app.security package at all.  zope.app.securitypolicy.intefaces
+        will be the preferred location from which to import these values.
+
       - Added xmlrpclib.ServerProxy variation in zope.app.testing.xmlrpc
         that allows testing XML-RPC views in functional tests.
 
@@ -178,7 +184,7 @@
     Much thanks to everyone who contributed to this release:
 
       Jim Fulton, Dmitry Vasiliev, Martijn Faassen, Christian Theune, Wolfgang
-      Schnerring
+      Schnerring, Fred Drake
 
   ------------------------------------------------------------------
 

Modified: Zope3/trunk/src/zope/app/securitypolicy/browser/granting.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/browser/granting.py	2006-09-19 15:40:46 UTC (rev 70227)
+++ Zope3/trunk/src/zope/app/securitypolicy/browser/granting.py	2006-09-19 16:31:47 UTC (rev 70228)
@@ -28,18 +28,18 @@
 from zope.app.i18n import ZopeMessageFactory as _
 
 from zope.app.form.interfaces import IInputWidget
+from zope.app.securitypolicy.interfaces import Allow, Unset, Deny
 from zope.app.securitypolicy.interfaces import IPrincipalPermissionManager
 from zope.app.securitypolicy.interfaces import IPrincipalRoleManager
 from zope.app.securitypolicy.interfaces import IRole
 from zope.app.securitypolicy.vocabulary import GrantVocabulary
 from zope.app.security.interfaces import IPermission
-from zope.app.security import settings
 
 
 settings_vocabulary = GrantVocabulary(
-    [SimpleTerm(settings.Allow, token="allow", title=_('Allow')),
-     SimpleTerm(settings.Unset, token="unset", title=_('Unset')),
-     SimpleTerm(settings.Deny,  token='deny',  title=_('Deny')),
+    [SimpleTerm(Allow, token="allow", title=_('Allow')),
+     SimpleTerm(Unset, token="unset", title=_('Unset')),
+     SimpleTerm(Deny,  token='deny',  title=_('Deny')),
      ])
 
 
@@ -206,10 +206,10 @@
                     pass
                 else:
                     # Arrgh!
-                    if setting is settings.Allow:
+                    if setting is Allow:
                         principal_roles.assignRoleToPrincipal(
                             role.id, principal)
-                    elif setting is settings.Deny:
+                    elif setting is Deny:
                         principal_roles.removeRoleFromPrincipal(
                             role.id, principal)
                     else:
@@ -228,10 +228,10 @@
                     pass
                 else:
                     # Arrgh!
-                    if setting is settings.Allow:
+                    if setting is Allow:
                         principal_perms.grantPermissionToPrincipal(
                             perm.id, principal)
-                    elif setting is settings.Deny:
+                    elif setting is Deny:
                         principal_perms.denyPermissionToPrincipal(
                             perm.id, principal)
                     else:

Modified: Zope3/trunk/src/zope/app/securitypolicy/browser/granting.txt
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/browser/granting.txt	2006-09-19 15:40:46 UTC (rev 70227)
+++ Zope3/trunk/src/zope/app/securitypolicy/browser/granting.txt	2006-09-19 16:31:47 UTC (rev 70228)
@@ -162,7 +162,7 @@
 
 Now we change some settings and submit the form:
 
-  >>> from zope.app.security import settings
+  >>> from zope.app.securitypolicy.interfaces import Allow, Deny, Unset
 
   >>> view.request.form['field.amlt.role.role1'] = 'unset'
   >>> view.request.form['field.amlt.role.role1-empty-makrer'] = 1
@@ -187,17 +187,17 @@
   u'Grants updated.'
 
   >>> roles = IPrincipalRoleManager(ob)
-  >>> roles.getSetting('role1', 'jim') is settings.Unset
+  >>> roles.getSetting('role1', 'jim') is Unset
   True
-  >>> roles.getSetting('role2', 'jim') is settings.Allow
+  >>> roles.getSetting('role2', 'jim') is Allow
   True
-  >>> roles.getSetting('role3', 'jim') is settings.Deny
+  >>> roles.getSetting('role3', 'jim') is Deny
   True
 
   >>> roles = IPrincipalPermissionManager(ob)
-  >>> roles.getSetting('permission1', 'jim') is settings.Unset
+  >>> roles.getSetting('permission1', 'jim') is Unset
   True
-  >>> roles.getSetting('permission2', 'jim') is settings.Allow
+  >>> roles.getSetting('permission2', 'jim') is Allow
   True
-  >>> roles.getSetting('permission3', 'jim') is settings.Deny
+  >>> roles.getSetting('permission3', 'jim') is Deny
   True

Modified: Zope3/trunk/src/zope/app/securitypolicy/browser/rolepermissionview.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/browser/rolepermissionview.py	2006-09-19 15:40:46 UTC (rev 70227)
+++ Zope3/trunk/src/zope/app/securitypolicy/browser/rolepermissionview.py	2006-09-19 16:31:47 UTC (rev 70228)
@@ -23,8 +23,8 @@
 
 from zope.app import zapi
 from zope.app.i18n import ZopeMessageFactory as _
-from zope.app.security.settings import Unset, Allow, Deny
 from zope.app.security.interfaces import IPermission
+from zope.app.securitypolicy.interfaces import Unset, Allow, Deny
 from zope.app.securitypolicy.interfaces import IRole, IRolePermissionManager
 
 class RolePermissionView(object):

Modified: Zope3/trunk/src/zope/app/securitypolicy/browser/tests/rolepermissionmanager.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/browser/tests/rolepermissionmanager.py	2006-09-19 15:40:46 UTC (rev 70227)
+++ Zope3/trunk/src/zope/app/securitypolicy/browser/tests/rolepermissionmanager.py	2006-09-19 16:31:47 UTC (rev 70228)
@@ -16,10 +16,10 @@
 $Id$
 """
 from zope.interface import implements
+from zope.app.securitypolicy.interfaces import Allow, Deny, Unset
 from zope.app.securitypolicy.interfaces import IRolePermissionManager
 from zope.app.securitypolicy.interfaces import IRolePermissionMap
 from zope.app.securitypolicy.securitymap import SecurityMap
-from zope.app.security.settings import Allow, Deny, Unset
 
 class RolePermissionManager(object):
     """

Modified: Zope3/trunk/src/zope/app/securitypolicy/grantinfo.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/grantinfo.py	2006-09-19 15:40:46 UTC (rev 70227)
+++ Zope3/trunk/src/zope/app/securitypolicy/grantinfo.py	2006-09-19 16:31:47 UTC (rev 70228)
@@ -16,7 +16,7 @@
 $Id$
 """
 from zope.annotation.interfaces import IAnnotations
-from zope.app.security.settings import Unset
+from zope.app.securitypolicy.interfaces import Unset
 from zope.app.securitypolicy.interfaces import IGrantInfo
 
 from zope.app.securitypolicy.principalpermission \

Modified: Zope3/trunk/src/zope/app/securitypolicy/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/interfaces.py	2006-09-19 15:40:46 UTC (rev 70227)
+++ Zope3/trunk/src/zope/app/securitypolicy/interfaces.py	2006-09-19 16:31:47 UTC (rev 70228)
@@ -13,11 +13,23 @@
 ##############################################################################
 """Security map to hold matrix-like relationships.
 
+In all cases, 'setting' values are one of the defined constants
+`Allow`, `Deny`, or `Unset`.
+
 $Id$
 """
 from zope.interface import Interface
 from zope.schema import TextLine, Text
 
+
+# These are the "setting" values returned by several methods defined
+# in these interfaces.  The implementation may move to another
+# location in the future, so this should be the preferred module to
+# import these from.
+#
+from zope.app.security.settings import Allow, Deny, Unset
+
+
 class IRole(Interface):
     """A role object."""
 

Modified: Zope3/trunk/src/zope/app/securitypolicy/principalpermission.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/principalpermission.py	2006-09-19 15:40:46 UTC (rev 70227)
+++ Zope3/trunk/src/zope/app/securitypolicy/principalpermission.py	2006-09-19 16:31:47 UTC (rev 70228)
@@ -19,8 +19,8 @@
 from zope.interface import implements
 from zope.security.permission import allPermissions
 
-from zope.app.security.settings import Allow, Deny, Unset
 from zope.app.security.principal import checkPrincipal
+from zope.app.securitypolicy.interfaces import Allow, Deny, Unset
 from zope.app.securitypolicy.interfaces import IPrincipalPermissionManager
 from zope.app.securitypolicy.securitymap import SecurityMap
 from zope.app.securitypolicy.securitymap import AnnotationSecurityMap

Modified: Zope3/trunk/src/zope/app/securitypolicy/principalrole.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/principalrole.py	2006-09-19 15:40:46 UTC (rev 70227)
+++ Zope3/trunk/src/zope/app/securitypolicy/principalrole.py	2006-09-19 16:31:47 UTC (rev 70228)
@@ -17,9 +17,9 @@
 """
 from zope.interface import implements
 
+from zope.app.securitypolicy.interfaces import Allow, Deny, Unset
 from zope.app.securitypolicy.interfaces import IPrincipalRoleManager
 
-from zope.app.security.settings import Allow, Deny, Unset
 from zope.app.securitypolicy.securitymap import SecurityMap
 from zope.app.securitypolicy.securitymap import AnnotationSecurityMap
 

Modified: Zope3/trunk/src/zope/app/securitypolicy/rolepermission.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/rolepermission.py	2006-09-19 15:40:46 UTC (rev 70227)
+++ Zope3/trunk/src/zope/app/securitypolicy/rolepermission.py	2006-09-19 16:31:47 UTC (rev 70228)
@@ -18,9 +18,9 @@
 from zope.interface import implements
 
 from zope.security.permission import allPermissions
-from zope.app.security.settings import Allow, Deny, Unset
 from zope.app.securitypolicy.role import checkRole
 
+from zope.app.securitypolicy.interfaces import Allow, Deny, Unset
 from zope.app.securitypolicy.interfaces import IRolePermissionManager
 from zope.app.securitypolicy.interfaces import IRolePermissionMap
 from zope.app.securitypolicy.securitymap import AnnotationSecurityMap

Modified: Zope3/trunk/src/zope/app/securitypolicy/tests/test_annotationprincipalpermissionmanager.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/tests/test_annotationprincipalpermissionmanager.py	2006-09-19 15:40:46 UTC (rev 70227)
+++ Zope3/trunk/src/zope/app/securitypolicy/tests/test_annotationprincipalpermissionmanager.py	2006-09-19 16:31:47 UTC (rev 70228)
@@ -25,9 +25,9 @@
 
 from zope.app.testing import ztapi
 from zope.app.security.principalregistry import principalRegistry
-from zope.app.security.settings import Allow, Deny, Unset
 from zope.app.testing.placelesssetup import PlacelessSetup
 
+from zope.app.securitypolicy.interfaces import Allow, Deny, Unset
 from zope.app.securitypolicy.principalpermission \
     import AnnotationPrincipalPermissionManager
 

Modified: Zope3/trunk/src/zope/app/securitypolicy/tests/test_annotationprincipalrolemanager.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/tests/test_annotationprincipalrolemanager.py	2006-09-19 15:40:46 UTC (rev 70227)
+++ Zope3/trunk/src/zope/app/securitypolicy/tests/test_annotationprincipalrolemanager.py	2006-09-19 16:31:47 UTC (rev 70228)
@@ -22,12 +22,12 @@
 
 from zope.app.testing import ztapi
 from zope.app.security.principalregistry import principalRegistry
-from zope.app.security.settings import Allow, Deny
 from zope.app.component.testing import PlacefulSetup
 
+from zope.app.securitypolicy.principalrole import AnnotationPrincipalRoleManager
+from zope.app.securitypolicy.interfaces import Allow, Deny
+from zope.app.securitypolicy.interfaces import IRole
 from zope.app.securitypolicy.role import Role
-from zope.app.securitypolicy.interfaces import IRole
-from zope.app.securitypolicy.principalrole import AnnotationPrincipalRoleManager
 
 class Manageable(object):
     implements(IAttributeAnnotatable)

Modified: Zope3/trunk/src/zope/app/securitypolicy/tests/test_annotationrolepermissionmanager.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/tests/test_annotationrolepermissionmanager.py	2006-09-19 15:40:46 UTC (rev 70227)
+++ Zope3/trunk/src/zope/app/securitypolicy/tests/test_annotationrolepermissionmanager.py	2006-09-19 16:31:47 UTC (rev 70228)
@@ -22,10 +22,10 @@
 from zope.security.permission import Permission
 
 from zope.app.testing import ztapi
-from zope.app.security.settings import Allow, Deny
 from zope.app.component.testing import PlacefulSetup
 
 from zope.app.securitypolicy.role import Role
+from zope.app.securitypolicy.interfaces import Allow, Deny
 from zope.app.securitypolicy.interfaces import IRole
 from zope.app.securitypolicy.rolepermission \
      import AnnotationRolePermissionManager

Modified: Zope3/trunk/src/zope/app/securitypolicy/tests/test_principalpermissionmanager.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/tests/test_principalpermissionmanager.py	2006-09-19 15:40:46 UTC (rev 70227)
+++ Zope3/trunk/src/zope/app/securitypolicy/tests/test_principalpermissionmanager.py	2006-09-19 16:31:47 UTC (rev 70228)
@@ -23,9 +23,9 @@
 from zope.app.testing import ztapi
 from zope.app.testing.placelesssetup import PlacelessSetup
 from zope.app.security.interfaces import IAuthentication
-from zope.app.security.settings import Allow, Deny, Unset
 from zope.app.security.principalregistry import principalRegistry
 
+from zope.app.securitypolicy.interfaces import Allow, Deny, Unset
 from zope.app.securitypolicy.principalpermission \
     import principalPermissionManager as manager
 

Modified: Zope3/trunk/src/zope/app/securitypolicy/tests/test_principalrolemanager.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/tests/test_principalrolemanager.py	2006-09-19 15:40:46 UTC (rev 70227)
+++ Zope3/trunk/src/zope/app/securitypolicy/tests/test_principalrolemanager.py	2006-09-19 16:31:47 UTC (rev 70228)
@@ -22,10 +22,10 @@
 from zope.app.testing.placelesssetup import PlacelessSetup
 
 from zope.app.security.interfaces import IAuthentication
-from zope.app.security.settings import Allow, Deny
 from zope.app.security.principalregistry import principalRegistry
 
 from zope.app.securitypolicy.role import Role
+from zope.app.securitypolicy.interfaces import Allow, Deny
 from zope.app.securitypolicy.interfaces import IRole
 from zope.app.securitypolicy.principalrole import principalRoleManager
 

Modified: Zope3/trunk/src/zope/app/securitypolicy/tests/test_rolepermissionmanager.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/tests/test_rolepermissionmanager.py	2006-09-19 15:40:46 UTC (rev 70227)
+++ Zope3/trunk/src/zope/app/securitypolicy/tests/test_rolepermissionmanager.py	2006-09-19 16:31:47 UTC (rev 70228)
@@ -22,8 +22,8 @@
 
 from zope.app.testing.placelesssetup import PlacelessSetup
 from zope.app.testing import ztapi
-from zope.app.security.settings import Allow, Deny
 from zope.app.securitypolicy.role import Role
+from zope.app.securitypolicy.interfaces import Allow, Deny
 from zope.app.securitypolicy.interfaces import IRole
 from zope.app.securitypolicy.rolepermission \
         import rolePermissionManager as manager

Modified: Zope3/trunk/src/zope/app/securitypolicy/tests/test_securitydirectives.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/tests/test_securitydirectives.py	2006-09-19 15:40:46 UTC (rev 70227)
+++ Zope3/trunk/src/zope/app/securitypolicy/tests/test_securitydirectives.py	2006-09-19 16:31:47 UTC (rev 70228)
@@ -26,10 +26,10 @@
 from zope.app.testing import ztapi
 from zope.app.testing.placelesssetup import PlacelessSetup
 from zope.app.security.interfaces import IAuthentication
-from zope.app.security.settings import Allow
 from zope.app.security.principalregistry import principalRegistry
 
 from zope.app.securitypolicy.role import Role
+from zope.app.securitypolicy.interfaces import Allow
 from zope.app.securitypolicy.interfaces import IRole
 from zope.app.securitypolicy.rolepermission \
         import rolePermissionManager as role_perm_mgr

Modified: Zope3/trunk/src/zope/app/securitypolicy/zopepolicy.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/zopepolicy.py	2006-09-19 15:40:46 UTC (rev 70227)
+++ Zope3/trunk/src/zope/app/securitypolicy/zopepolicy.py	2006-09-19 16:31:47 UTC (rev 70228)
@@ -27,7 +27,6 @@
 from zope.app import zapi
 
 from zope.app.security.interfaces import PrincipalLookupError
-from zope.app.security.settings import Allow, Deny, Unset
 
 from zope.app.securitypolicy.principalpermission \
      import principalPermissionManager
@@ -39,6 +38,7 @@
 from zope.app.securitypolicy.principalrole import principalRoleManager
 globalRolesForPrincipal = principalRoleManager.getRolesForPrincipal
 
+from zope.app.securitypolicy.interfaces import Allow, Deny, Unset
 from zope.app.securitypolicy.interfaces import IRolePermissionMap
 from zope.app.securitypolicy.interfaces import IPrincipalPermissionMap
 from zope.app.securitypolicy.interfaces import IPrincipalRoleMap



More information about the Zope3-Checkins mailing list