home / docs / sections

sections

1 row where page = "plugin_hooks", references = "[]" and title = "Default deny with an exception"

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: breadcrumbs (array)

id ▼ page ref title content breadcrumbs references
plugin_hooks:default-deny-with-an-exception plugin_hooks default-deny-with-an-exception Default deny with an exception Combine a root-level deny with a specific table allow for trusted users. The resolver will automatically apply the most specific rule. from datasette import hookimpl from datasette.permissions import PermissionSQL TRUSTED = {"alice", "bob"} @hookimpl def permission_resources_sql(datasette, actor, action): if action != "view-table": return None actor_id = (actor or {}).get("id") if actor_id not in TRUSTED: return PermissionSQL( sql=""" SELECT NULL AS parent, NULL AS child, 0 AS allow, 'default deny view-table' AS reason """, ) return PermissionSQL( sql=""" SELECT NULL AS parent, NULL AS child, 0 AS allow, 'default deny view-table' AS reason UNION ALL SELECT 'reports' AS parent, 'daily_metrics' AS child, 1 AS allow, 'trusted user access' AS reason """, params={"actor_id": actor_id}, ) The UNION ALL ensures the deny rule is always present, while the second row adds the exception for trusted users. ["Plugin hooks", "permission_resources_sql(datasette, actor, action)", "Permission plugin examples"] []

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE [sections] (
   [id] TEXT PRIMARY KEY,
   [page] TEXT,
   [ref] TEXT,
   [title] TEXT,
   [content] TEXT,
   [breadcrumbs] TEXT,
   [references] TEXT
);
Powered by Datasette · Queries took 1.2ms