Commit 5866524f authored by Andreas Jung's avatar Andreas Jung

using isinstance()

parent f291b685
......@@ -275,8 +275,7 @@ def absattr(attr):
if callable(attr): return attr()
return attr
def ownerInfo(user,
getattr=getattr, type=type, st=type('')):
def ownerInfo(user, getattr=getattr):
if user is None:
return None
uid=user.getId()
......@@ -290,7 +289,7 @@ def ownerInfo(user,
db=db.aq_parent
if db is root: break
id=db.id
if type(id) is not st:
if not isinstance(id, str):
try: id=id()
except: id=str(id)
path.append(id)
......
......@@ -14,9 +14,9 @@
$Id$
"""
import string, Products, Globals
ListType=type([])
name_trans=filter(lambda c, an=string.letters+string.digits+'_': c not in an,
map(chr,range(256)))
......@@ -83,7 +83,7 @@ class Permission:
def setRoles(self, roles):
obj=self.obj
if type(roles) is ListType and not roles:
if isinstance(roles, list) and not roles:
if hasattr(obj, self._p): delattr(obj, self._p)
else:
setattr(obj, self._p, roles)
......@@ -100,14 +100,14 @@ class Permission:
roles=self.getRoles()
if role in roles:
if present: return
if type(roles) is ListType: roles.remove(role)
if isinstance(roles, list): roles.remove(role)
else:
roles=list(roles)
roles.remove(role)
roles=tuple(roles)
elif not present: return
else:
if type(roles) is ListType: roles.append(role)
if isinstance(roles, list): roles.append(role)
else: roles=roles+(role,)
self.setRoles(roles)
......
......@@ -21,7 +21,6 @@ from Permission import Permission
from App.Common import aq_base
from cgi import escape
ListType=type([])
DEFAULTMAXLISTUSERS=250
......@@ -109,7 +108,7 @@ class RoleManager(ExtensionClass.Base, PermissionMapping.RoleManager):
p=Permission(name,value,self)
roles=p.getRoles(default=[])
d={'name': name,
'acquire': type(roles) is ListType and 'CHECKED' or '',
'acquire': isinstance(roles, list) and 'CHECKED' or '',
'roles': map(
lambda ir, roles=roles, valid=valid, ip=ip:
{
......@@ -262,7 +261,7 @@ class RoleManager(ExtensionClass.Base, PermissionMapping.RoleManager):
if name==permission:
p=Permission(name,value,self)
roles=p.getRoles()
return type(roles) is ListType and 'CHECKED' or ''
return isinstance(roles, list) and 'CHECKED' or ''
raise ValueError, (
"The permission <em>%s</em> is invalid." % escape(permission))
......@@ -317,7 +316,7 @@ class RoleManager(ExtensionClass.Base, PermissionMapping.RoleManager):
aclu = getattr(aq_base(item), '__allow_groups__', _notfound)
if aclu is not _notfound:
mlu = getattr(aclu, 'maxlistusers', _notfound)
if type(mlu) != type(1): mlu = DEFAULTMAXLISTUSERS
if not isinstance(mlu, int): mlu = DEFAULTMAXLISTUSERS
if mlu < 0: raise OverflowError
un = getattr(aclu, 'user_names', _notfound)
if un is not _notfound:
......
......@@ -126,7 +126,7 @@ class SecurityInfo(Acquisition.Implicit):
This should be a boolean value, a map of attribute names to
booleans, or a callable (name, value) -> boolean.
"""
if type(access) == type(''):
if isinstance(access, str):
access = access.lower()
if access == 'allow':
access = 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment