home / docs / sections

sections

1 row where page = "plugin_hooks", references = "[]" and title = "Read permissions from a custom table"

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: breadcrumbs (array)

id ▼ page ref title content breadcrumbs references
plugin_hooks:read-permissions-from-a-custom-table plugin_hooks read-permissions-from-a-custom-table Read permissions from a custom table This example stores grants in an internal table called permission_grants with columns (actor_id, action, parent, child, allow, reason) . from datasette import hookimpl from datasette.permissions import PermissionSQL @hookimpl def permission_resources_sql(datasette, actor, action): if not actor: return None return PermissionSQL( sql=""" SELECT parent, child, allow, COALESCE(reason, 'permission_grants table') AS reason FROM permission_grants WHERE actor_id = :grants_actor_id AND action = :grants_action """, params={ "grants_actor_id": actor.get("id"), "grants_action": action, }, ) ["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