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

@ -819,6 +819,16 @@ class Datasette:
)
return crumbs
async def actors_from_ids(
self, actor_ids: Iterable[Union[str, int]]
) -> Dict[Union[id, str], Dict]:
result = pm.hook.actors_from_ids(datasette=self, actor_ids=actor_ids)
if result is None:
# Do the default thing
return {actor_id: {"id": actor_id} for actor_id in actor_ids}
result = await await_me_maybe(result)
return result
async def permission_allowed(
self, actor, action, resource=None, default=DEFAULT_NOT_SET
):