sections
1 row where page = "plugin_hooks", references = "[]" and title = "register_actions(datasette)"
This data as json, CSV (advanced)
Suggested facets: breadcrumbs (array)
| id ▼ | page | ref | title | content | breadcrumbs | references |
|---|---|---|---|---|---|---|
| plugin_hooks:plugin-register-actions | plugin_hooks | plugin-register-actions | register_actions(datasette) | If your plugin needs to register actions that can be checked with Datasette's new resource-based permission system, return a list of those actions from this hook. Actions define what operations can be performed on resources (like viewing a table, executing SQL, or custom plugin actions). from datasette import hookimpl from datasette.permissions import Action, Resource class DocumentCollectionResource(Resource): """A collection of documents.""" name = "document-collection" parent_class = None def __init__(self, collection: str): super().__init__(parent=collection, child=None) @classmethod async def resources_sql( cls, datasette, actor=None ) -> str: return """ SELECT collection_name AS parent, NULL AS child FROM document_collections """ class DocumentResource(Resource): """A document in a collection.""" name = "document" parent_class = DocumentCollectionResource def __init__(self, collection: str, document: str): super().__init__(parent=collection, child=document) @classmethod async def resources_sql( cls, datasette, actor=None ) -> str: return """ SELECT collection_name AS parent, document_id AS child FROM documents """ @hookimpl def register_actions(datasette): return [ Action( name="list-documents", abbr="ld", description="List documents in a collection", resource_class=DocumentCollectionResource, ), Action( name="view-document", abbr="vdoc", description="View document", resource_class=DocumentResource, ), Action( name="edit-document", abbr="edoc", description="Edit document", resource_class=DocumentResource, ), ] The fields of the Action dataclass are as follows: … | ["Plugin hooks"] | [] |
Advanced export
JSON shape: default, array, newline-delimited, object
CREATE TABLE [sections] ( [id] TEXT PRIMARY KEY, [page] TEXT, [ref] TEXT, [title] TEXT, [content] TEXT, [breadcrumbs] TEXT, [references] TEXT );