Skip to content

Commit f18687f

Browse files
committed
Rename parameter of hasPermission
Rename only_no_check to skip_permissions_with_check. Revert explicit no-properties check in Permission.searchable, this check is already taken care of by the _properties_dict check. Add a comment on what _properties_dict does.
1 parent 0b7acad commit f18687f

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

roundup/hyperdb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1817,7 +1817,7 @@ def filter_with_permissions(self, search_matches, filterspec, sort=[],
18171817
item_ids = self.filter(search_matches, filterspec, sort, group,
18181818
retired, exact_match_spec, limit, offset)
18191819
check = sec.hasPermission
1820-
if check(permission, userid, cn, only_no_check = True):
1820+
if check(permission, userid, cn, skip_permissions_with_check = True):
18211821
allowed = item_ids
18221822
else:
18231823
debug = self.db.config.RDBMS_DEBUG_FILTER

roundup/security.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ def test(self, db, permission, classname, property, userid, itemid):
122122
return 0
123123

124124
# what about property?
125+
# Note that _properties_dict always returns True if it was
126+
# initialized with empty properties
125127
if property is not None and not self._properties_dict[property]:
126128
return 0
127129

@@ -159,11 +161,9 @@ def searchable(self, classname, property):
159161
if self.check:
160162
return 0
161163

162-
# Allow if we have access to *all* properties
163-
if self.properties is None:
164-
return 1
165-
166164
# what about property?
165+
# Note that _properties_dict always returns True if it was
166+
# initialized with empty properties
167167
if not self._properties_dict[property]:
168168
return 0
169169

@@ -362,7 +362,8 @@ def getPermission(self, permission, classname=None, properties=None,
362362
classname))
363363

364364
def hasPermission(self, permission, userid, classname=None,
365-
property=None, itemid=None, only_no_check=False):
365+
property=None, itemid=None,
366+
skip_permissions_with_check=False):
366367
'''Look through all the Roles, and hence Permissions, and
367368
see if "permission" exists given the constraints of
368369
classname, property, itemid, and props_only.
@@ -398,7 +399,7 @@ def hasPermission(self, permission, userid, classname=None,
398399
# expensive than the ones without. So we check the ones without
399400
# a check method first
400401
checklist = (False, True)
401-
if only_no_check:
402+
if skip_permissions_with_check:
402403
checklist = (False,)
403404
for has_check in checklist:
404405
for rolename in self.db.user.get_roles(userid):

0 commit comments

Comments
 (0)