home / docs / sections

sections: plugin_hooks:read-permissions-from-a-custom-table

This data as json

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"] []
Powered by Datasette · Queries took 4.131ms