[Zope3-checkins] CVS: Zope3/src/zope/app/security - zopepolicy.py:1.11 permission.py:1.8 loginpassword.py:1.3

Steve Alexander steve@cat-box.net
Tue, 3 Jun 2003 11:45:40 -0400


Update of /cvs-repository/Zope3/src/zope/app/security
In directory cvs.zope.org:/tmp/cvs-serv9102/src/zope/app/security

Modified Files:
	zopepolicy.py permission.py loginpassword.py 
Log Message:
Various formatting cleanup.
Use new implements() style.
replaced use of 0 and 1 with False and True.


=== Zope3/src/zope/app/security/zopepolicy.py 1.10 => 1.11 ===
--- Zope3/src/zope/app/security/zopepolicy.py:1.10	Mon Jun  2 12:55:47 2003
+++ Zope3/src/zope/app/security/zopepolicy.py	Tue Jun  3 11:45:10 2003
@@ -30,6 +30,7 @@
 from zope.app.security.grants.rolepermission import rolePermissionManager
 from zope.app.security.grants.principalrole import principalRoleManager
 from zope.app.security.settings import Allow, Deny
+from zope.interface import implements
 
 getPermissionsForPrincipal = \
                 principalPermissionManager.getPermissionsForPrincipal
@@ -39,12 +40,11 @@
 globalContext = object()
 
 
-
 class ZopeSecurityPolicy:
 
-    __implements__ = ISecurityPolicy
+    implements(ISecurityPolicy)
 
-    def __init__(self, ownerous=1, authenticated=1):
+    def __init__(self, ownerous=True, authenticated=True):
         """
             Two optional keyword arguments may be provided:
 
@@ -76,7 +76,7 @@
         # mapping from principal to set of roles
         user = context.user
         if user is system_user:
-            return 1
+            return True
 
         roledict = {'Anonymous': Allow}
         principals = {user.getId() : roledict}
@@ -92,9 +92,9 @@
                 getPermissionsForPrincipal(principal)):
                 if principal_permission == permission:
                     if setting is Deny:
-                        return 0
+                        return False
                     assert setting is Allow
-                    remove[principal] = 1
+                    remove[principal] = True
 
         # Clean out removed principals
         if remove:
@@ -105,8 +105,7 @@
                 remove.clear()
             else:
                 # we've eliminated all the principals
-                return 1
-
+                return True
 
         # get placeless principal roles
         for principal in principals:
@@ -133,8 +132,8 @@
                     if permission in role_permissions[role]:
                         setting = role_permissions[role][permission]
                         if setting is Deny:
-                            return 0
-                        remove[principal] = 1
+                            return False
+                        remove[principal] = True
 
 
         # Clean out removed principals
@@ -146,7 +145,7 @@
                 remove.clear()
             else:
                 # we've eliminated all the principals
-                return 1
+                return True
 
         # Look for placeful grants
         for place in ContainmentIterator(object):
@@ -159,10 +158,10 @@
                         prinper.getPermissionsForPrincipal(principal)):
                         if principal_permission == permission:
                             if setting is Deny:
-                                return 0
+                                return False
 
                             assert setting is Allow
-                            remove[principal] = 1
+                            remove[principal] = True
 
             # Clean out removed principals
             if remove:
@@ -173,7 +172,7 @@
                     remove.clear()
                 else:
                     # we've eliminated all the principals
-                    return 1
+                    return True
 
             # Collect principal roles
             prinrole = queryAdapter(place, IPrincipalRoleMap)
@@ -205,8 +204,8 @@
                         if permission in role_permissions[role]:
                             setting = role_permissions[role][permission]
                             if setting is Deny:
-                                return 0
-                            remove[principal] = 1
+                                return False
+                            remove[principal] = True
 
             # Clean out removed principals
             if remove:
@@ -217,9 +216,9 @@
                     remove.clear()
                 else:
                     # we've eliminated all the principals
-                    return 1
+                    return True
 
-        return 0 # deny by default
+        return False # deny by default
 
 
 def permissionsOfPrincipal(principal, object):


=== Zope3/src/zope/app/security/permission.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/security/permission.py:1.7	Mon Apr 14 14:21:36 2003
+++ Zope3/src/zope/app/security/permission.py	Tue Jun  3 11:45:10 2003
@@ -22,16 +22,17 @@
 from zope.app.services.servicenames import Permissions
 from zope.app.interfaces.security import IPermissionField
 from zope.security.checker import CheckerPublic
+from zope.interface import implements
 
 
 def checkPermission(context, permission_id):
-    
+
     if not getService(context, Permissions).getPermission(permission_id):
         raise ValueError("Undefined permission id", permission_id)
 
 class PermissionField(Enumerated, Field):
     __doc__ = IPermissionField.__doc__
-    __implements__ = IPermissionField
+    implements(IPermissionField)
 
     def _validate(self, value):
         if value is CheckerPublic:


=== Zope3/src/zope/app/security/loginpassword.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/security/loginpassword.py:1.2	Wed Dec 25 09:13:15 2002
+++ Zope3/src/zope/app/security/loginpassword.py	Tue Jun  3 11:45:10 2003
@@ -12,10 +12,11 @@
 #
 ##############################################################################
 from zope.app.interfaces.security import ILoginPassword
+from zope.interface import implements
 
 class LoginPassword:
 
-    __implements__ = ILoginPassword
+    implements(ILoginPassword)
 
     def __init__(self, login, password):
         self.__login = login