changeset 8133:7b6615fb37fc permission-performance

Add documentation for the filter function
author Ralf Schlatterbeck <rsc@runtux.com>
date Wed, 23 Oct 2024 14:49:45 +0200
parents 603aa730b067
children 132d450bdc00
files doc/design.txt doc/reference.txt
diffstat 2 files changed, 22 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/doc/design.txt	Tue Oct 22 16:10:29 2024 +0200
+++ b/doc/design.txt	Wed Oct 23 14:49:45 2024 +0200
@@ -1524,6 +1524,7 @@
             - klass (optional)
             - properties (optional)
             - check function (optional)
+            - filter function (optional)
 
             The klass may be unset, indicating that this permission is
             not locked to a particular hyperdb class. There may be
@@ -1536,6 +1537,16 @@
             If check function is set, permission is granted only when
             the function returns value interpreted as boolean true.
             The function is called with arguments db, userid, itemid.
+
+            A filter function complements a check function: It is used
+            when searching for viewable items. The filter function
+            allows to filter in SQL rather than calling the check
+            function for each item after a query. It must return a list
+            of dictionaries containing parameters for the hyperdb.Class.filter
+            method. An empty list indicates no access. The signature of
+            the filter function is::
+
+                def filter(db, userid, klass):
         '''
 
     class Role:
--- a/doc/reference.txt	Tue Oct 22 16:10:29 2024 +0200
+++ b/doc/reference.txt	Wed Oct 23 14:49:45 2024 +0200
@@ -1482,7 +1482,7 @@
 4. check it in the appropriate hasPermission methods in your tracker's
    extensions/detectors/interfaces.py modules
 
-The ``addPermission`` method takes a three optional parameters:
+The ``addPermission`` method takes a four optional parameters:
 
 **check**
   A function to be executed which returns boolean determining whether
@@ -1565,6 +1565,16 @@
 
      **Invalid properties for file: ['summary']
 
+**filter
+  A function that complements a check function: It is used when
+  searching for viewable items. The filter function allows to filter in
+  SQL (for an SQL backend) rather than calling the check function for
+  each item after a query. It must return a list of dictionaries
+  containing parameters for the hyperdb.Class.filter method. An empty
+  list indicates no access. The signature of the filter function is::
+
+    def filter(db, userid, klass):
+
 
 Example Scenarios
 ~~~~~~~~~~~~~~~~~

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