diff roundup/security.py @ 8139:de58ff07890e permission-performance

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.
author Ralf Schlatterbeck <rsc@runtux.com>
date Thu, 24 Oct 2024 09:19:25 +0200
parents 8e9181dfc9fa
children e9af08743759
line wrap: on
line diff
--- a/roundup/security.py	Wed Oct 23 17:46:05 2024 +0200
+++ b/roundup/security.py	Thu Oct 24 09:19:25 2024 +0200
@@ -122,6 +122,8 @@
             return 0
 
         # what about property?
+        # Note that _properties_dict always returns True if it was
+        # initialized with empty properties
         if property is not None and not self._properties_dict[property]:
             return 0
 
@@ -159,11 +161,9 @@
         if self.check:
             return 0
 
-        # Allow if we have access to *all* properties
-        if self.properties is None:
-            return 1
-
         # what about property?
+        # Note that _properties_dict always returns True if it was
+        # initialized with empty properties
         if not self._properties_dict[property]:
             return 0
 
@@ -362,7 +362,8 @@
                                                                   classname))
 
     def hasPermission(self, permission, userid, classname=None,
-                      property=None, itemid=None, only_no_check=False):
+                      property=None, itemid=None,
+                      skip_permissions_with_check=False):
         '''Look through all the Roles, and hence Permissions, and
            see if "permission" exists given the constraints of
            classname, property, itemid, and props_only.
@@ -398,7 +399,7 @@
         # expensive than the ones without. So we check the ones without
         # a check method first
         checklist = (False, True)
-        if only_no_check:
+        if skip_permissions_with_check:
             checklist = (False,)
         for has_check in checklist:
             for rolename in self.db.user.get_roles(userid):

Roundup Issue Tracker: http://roundup-tracker.org/