actors_from_ids plugin hook and datasette.actors_from_ids() method (#2181)

* Prototype of actors_from_ids plugin hook, refs #2180
* datasette-remote-actors example plugin, refs #2180
This commit is contained in:
Simon Willison 2023-09-07 21:23:59 -07:00 committed by GitHub
commit b645174271
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 155 additions and 0 deletions

View file

@ -322,6 +322,27 @@ await .render_template(template, context=None, request=None)
Renders a `Jinja template <https://jinja.palletsprojects.com/en/2.11.x/>`__ using Datasette's preconfigured instance of Jinja and returns the resulting string. The template will have access to Datasette's default template functions and any functions that have been made available by other plugins.
.. _datasette_actors_from_ids:
await .actors_from_ids(actor_ids)
---------------------------------
``actor_ids`` - list of strings or integers
A list of actor IDs to look up.
Returns a dictionary, where the keys are the IDs passed to it and the values are the corresponding actor dictionaries.
This method is mainly designed to be used with plugins. See the :ref:`plugin_hook_actors_from_ids` documentation for details.
If no plugins that implement that hook are installed, the default return value looks like this:
.. code-block:: json
{
"1": {"id": "1"},
"2": {"id": "2"}
}
.. _datasette_permission_allowed:
await .permission_allowed(actor, action, resource=None, default=...)