labthings_fastapi.dependencies.action_manager
Context Var access to the Action Manager
This module provides a context var to access the Action Manager instance.
While LabThings tries pretty hard to conform to FastAPI’s excellent convention
that everything should be passed as a parameter, there are some cases where
that’s hard. In particular, generating URLs when responses are serialised is
difficult, because pydantic doesn’t have a way to pass in extra context.
If an endpoint uses the ActionManagerDep dependency, then the Action Manager
is available using ActionManagerContext.get().
Module Contents
Functions
Retrieve the Action Manager from the Thing Server |
|
Make the Action Manager available in the context |
Data
A ready-made dependency type for the |
|
API
- labthings_fastapi.dependencies.action_manager.action_manager_from_thing_server(request: fastapi.Request) labthings_fastapi.actions.ActionManager
Retrieve the Action Manager from the Thing Server
This is for use as a FastAPI dependency, so the thing server is retrieved from the request object.
- labthings_fastapi.dependencies.action_manager.ActionManagerDep
None
A ready-made dependency type for the
ActionManagerobject.
- labthings_fastapi.dependencies.action_manager.ActionManagerContext
‘(…)’
- async labthings_fastapi.dependencies.action_manager.make_action_manager_context_available(action_manager: labthings_fastapi.dependencies.action_manager.ActionManagerDep)
Make the Action Manager available in the context
The action manager may be accessed using
ActionManagerContext.get().
- labthings_fastapi.dependencies.action_manager.ActionManagerContextDep: typing_extensions.TypeAlias
None