Skip to content

Commit 2ec8995

Browse files
committed
Manually tweaked comments and docs
1 parent 902c7ea commit 2ec8995

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

datasette/permissions.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def private(self, value: bool):
5757
@classmethod
5858
def takes_parent(cls) -> bool:
5959
"""
60-
Whether actions on this resource require a parent identifier.
60+
Whether actions on this resource can work with a parent.
6161
6262
Returns True for parent-level and child-level resources.
6363
Returns False for top-level resources (where parent_class is None).
@@ -67,9 +67,8 @@ def takes_parent(cls) -> bool:
6767
@classmethod
6868
def takes_child(cls) -> bool:
6969
"""
70-
Whether actions on this resource require a child identifier.
70+
Whether actions on this resource can work with a child.
7171
72-
With the 2-level hierarchy constraint:
7372
- Top-level resources (no parent): False
7473
- Child-level resources (has parent): True
7574
"""
@@ -78,7 +77,7 @@ def takes_child(cls) -> bool:
7877
@classmethod
7978
def __init_subclass__(cls):
8079
"""
81-
Validate that resource hierarchy doesn't exceed 2 levels.
80+
Validate resource hierarchy doesn't exceed 2 levels.
8281
8382
Raises:
8483
ValueError: If this resource would create a 3-level hierarchy

docs/plugin_hooks.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -914,16 +914,16 @@ The fields of the ``Action`` dataclass are as follows:
914914
The Resource subclass that defines what kind of resource this action applies to. Omit this (or set to ``None``) for global actions that apply only at the instance level with no associated resources (like ``debug-menu`` or ``permissions-debug``). Your Resource subclass must:
915915

916916
- Define a ``name`` class attribute (e.g., ``"document"``)
917-
- Define a ``parent_class`` class attribute (``None`` for top-level resources like databases, or the parent ``Resource`` class for child resources)
917+
- Define a ``parent_class`` class attribute (``None`` for top-level resources like databases, or the parent ``Resource`` subclass for child resources)
918918
- Implement a ``resources_sql()`` classmethod that returns SQL returning all resources as ``(parent, child)`` columns
919919
- Have an ``__init__`` method that accepts appropriate parameters and calls ``super().__init__(parent=..., child=...)``
920920

921921
The ``resources_sql()`` method
922922
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
923923

924-
The ``resources_sql()`` classmethod is crucial to Datasette's permission system. It returns a SQL query that lists all resources of that type that exist in the system.
924+
The ``resources_sql()`` classmethod returns a SQL query that lists all resources of that type that exist in the system.
925925

926-
This SQL query is used by Datasette to efficiently check permissions across multiple resources at once. When a user requests a list of resources (like tables, documents, or other entities), Datasette uses this SQL to:
926+
This query is used by Datasette to efficiently check permissions across multiple resources at once. When a user requests a list of resources (like tables, documents, or other entities), Datasette uses this SQL to:
927927

928928
1. Get all resources of this type from your data catalog
929929
2. Combine it with permission rules from the ``permission_resources_sql`` hook

0 commit comments

Comments
 (0)