[Zope-Checkins] CVS: Zope27/lib/python/AccessControl - Owned.py:1.17.4.1 PermissionRole.py:1.15.72.1 ZopeSecurityPolicy.py:1.18.64.1

Fred L. Drake, Jr. fdrake@acm.org
Tue, 20 Aug 2002 16:34:16 -0400


Update of /cvs-repository/Zope27/lib/python/AccessControl
In directory cvs.zope.org:/tmp/cvs-serv11371/AccessControl

Modified Files:
      Tag: Zope-2_7-development-branch
	Owned.py PermissionRole.py ZopeSecurityPolicy.py 
Log Message:
Remove unnecessary aliasing.  Python 2.3 issues a SyntaxWarning when binding
to the name None.  Switch to using isinstance() in affected locations.


=== Zope27/lib/python/AccessControl/Owned.py 1.17 => 1.17.4.1 ===
--- Zope27/lib/python/AccessControl/Owned.py:1.17	Wed Jun 12 14:14:39 2002
+++ Zope27/lib/python/AccessControl/Owned.py	Tue Aug 20 16:34:15 2002
@@ -62,11 +62,7 @@
         return d
     
     getOwner__roles__=()
-    def getOwner(self, info=0,
-                 aq_get=aq_get, None=None,
-                 UnownableOwner=UnownableOwner,
-                 getSecurityManager=getSecurityManager,
-                 ):
+    def getOwner(self, info=0):
         """Get the owner
 
         If a true argument is provided, then only the owner path and id are
@@ -89,9 +85,7 @@
         return user
 
     changeOwnership__roles__=()
-    def changeOwnership(self, user, recursive=0,
-                        aq_get=aq_get, None=None,
-                        ):
+    def changeOwnership(self, user, recursive=0):
         """Change the ownership to the given user.  If 'recursive' is
         true then also take ownership of all sub-objects, otherwise
         sub-objects retain their ownership information."""
@@ -230,8 +224,7 @@
     if callable(attr): return attr()
     return attr
 
-def ownerInfo(user,
-              getattr=getattr, type=type, st=type(''), None=None):
+def ownerInfo(user):
     if user is None:
         return None
     uid=user.getId()
@@ -245,7 +238,7 @@
         db=db.aq_parent
         if db is root: break
         id=db.id
-        if type(id) is not st:
+        if isinstance(id, str):
             try: id=id()
             except: id=str(id)
         path.append(id)
@@ -253,4 +246,3 @@
     path.reverse()
 
     return path, uid
-


=== Zope27/lib/python/AccessControl/PermissionRole.py 1.15 => 1.15.72.1 ===
--- Zope27/lib/python/AccessControl/PermissionRole.py:1.15	Thu Dec 13 09:24:41 2001
+++ Zope27/lib/python/AccessControl/PermissionRole.py	Tue Aug 20 16:34:15 2002
@@ -66,7 +66,7 @@
             self._p='_'+string.translate(name,name_trans)+"_Permission"
             self._d=default
 
-        def __of__(self, parent, None=None, getattr=getattr):
+        def __of__(self, parent):
             r=imPermissionRole()
             r._p=self._p
             r._pa=parent
@@ -85,7 +85,7 @@
         """Implement permission-based roles
         """
 
-        def __of__(self, parent,tt=type(()),st=type(''),getattr=getattr,None=None):
+        def __of__(self, parent):
             obj=parent
             n=self._p
             r=None
@@ -95,14 +95,12 @@
 
                     if roles is None: return 'Anonymous',
 
-                    t=type(roles)
-
-                    if t is tt:
+                    if isinstance(roles, tuple):
                         # If we get a tuple, then we don't acquire
                         if r is None: return roles
                         return r+list(roles)
 
-                    if t is st:
+                    if isinstance(roles, str):
                         # We found roles set to a name.  Start over
                         # with the new permission name.  If the permission
                         # name is '', then treat as private!


=== Zope27/lib/python/AccessControl/ZopeSecurityPolicy.py 1.18 => 1.18.64.1 ===
--- Zope27/lib/python/AccessControl/ZopeSecurityPolicy.py:1.18	Fri Jan 11 12:14:27 2002
+++ Zope27/lib/python/AccessControl/ZopeSecurityPolicy.py	Tue Aug 20 16:34:15 2002
@@ -33,8 +33,6 @@
 
 if _use_python_impl:
 
-    from types import StringType
-
     import SimpleObjectPolicies
     from AccessControl import Unauthorized
     _noroles=SimpleObjectPolicies._noroles
@@ -75,16 +73,14 @@
             self._authenticated=authenticated
 
         def validate(self, accessed, container, name, value, context,
-                     roles=_noroles, None=None, type=type, IntType=type(0),
-                     DictType=type({}), getattr=getattr, _noroles=_noroles,
-                     StringType=type(''),
+                     roles=_noroles,
                      Containers=SimpleObjectPolicies.Containers,
                      valid_aq_=('aq_parent','aq_inner', 'aq_explicit')):
 
 
             ############################################################
             # Provide special rules for the acquisition attributes
-            if type(name) is StringType:
+            if isinstance(name, str):
                 if name.startswith('aq_') and name not in valid_aq_:
                     return 0
 
@@ -133,9 +129,8 @@
                               '__allow_access_to_unprotected_subobjects__', None)
 
                 if p is not None:
-                    tp=type(p)
-                    if tp is not IntType:
-                        if tp is DictType:
+                    if isinstance(p, int):
+                        if isinstance(p, dict):
                             p=p.get(name, None)
                         else:
                             p=p(name, value)
@@ -204,6 +199,6 @@
         def checkPermission(self, permission, object, context):
             # XXX proxy roles and executable owner are not checked
             roles=rolesForPermissionOn(permission, object)
-            if type(roles) is StringType:
+            if isinstance(roles, str):
                 roles=[roles]
             return context.user.allowed(object, roles)