Skip to content

settings — API Reference ​

python
from fastapi_viewsets.conf import settings

settings is the one instance of fastapi_viewsets.conf.Settings. The application assigns its attributes once, before any viewset class is decorated with route_viewset.

AttributeTypeDefaultDescription
viewsets_context_processorslist[ContextProcessor][]Build each request's context; see Context Processors
viewsets_context_json_encodertype[json.JSONEncoder] | NoneNoneEncodes context values that cross the Celery boundary
viewsets_context_json_decodertype[json.JSONDecoder] | NoneNoneDecodes them on the worker
viewsets_command_middlewarelist[CommandMiddleware][]Wraps every request-facing execution; see Command Middleware
viewsets_idempotency_ttlfloat86400Seconds an outcome recorded by Idempotency is kept; see Idempotent Calls
viewsets_idempotency_lock_ttlfloat600Seconds a running record of Idempotency is kept after it was last extended; the process running the call extends it every third of this time
viewsets_auth_processorslist[AuthBackend][]Tried in order to resolve context.user; see Authentication
default_action_configurationdict[Any, Any]{}The configuration every action starts from; see Action Configuration
default_list_shapestr"plain"The list shape of a viewset that states none: "plain", "paginated" or "cursor"
viewsets_register_muxwsboolTrueWhether a viewset is published on muxws when neither it nor its endpoint says; see muxws
viewsets_security_schemeSecurityBase | NoneNoneA FastAPI security scheme added to every route, for the OpenAPI "Authorize" flow only
viewsets_event_storeEventStore | NoneNoneThe event store; None is one MemoryEventStore per process. A deployment of more than one process sets a RedisEventStore in every process; see Events
viewsets_event_authorizerslist[EventAuthorizer][]Decide whether a caller may follow a topic, in list order; the first True admits, the first False refuses, no decision refuses
viewsets_event_delivery_filterslist[DeliveryFilter][]Decide per subscription and per event whether a push is sent, and per poll and per event whether the poll answers the event; False skips the socket or leaves the event out of the poll answer, an exception counts as True
viewsets_event_log_sizeint32Events kept per topic for poll
viewsets_event_log_ttlfloat60.0Seconds a topic's log is kept after its last event; the topic's rev is kept without expiry
viewsets_event_push_timeoutfloat2.0Seconds the delivery filters and peer.notify() of one push to one socket may take together; notify() queues the push and does not wait for the socket
viewsets_event_max_subscriptionsint256Topics one socket may hold, and cursors one poll may carry
viewsets_event_poll_after_msint0poll_after_ms of every poll answer, the shortest interval a client polls at

ContextProcessor is Callable[[Request, Any], Awaitable[dict[str, Any]]]; a processor may also take a config keyword, see Action Configuration.

viewsets_register_muxws and viewsets_security_scheme are read when a viewset is decorated, and so is whether an entry of viewsets_command_middleware declares modifies_response_shape: changed later, they do not reach viewsets already decorated. The middleware list itself, the processors, the auth backends, the idempotency TTLs and the viewsets_event_* settings are read on every use.

Other public classes ​

NameModuleDescription
SaveStatefastapi_viewsets.save_state.save_stateBase of a viewset that loads and saves its state around each call: load_state(), save_state(); see ViewSet Lifecycle
SaveStateRedisfastapi_viewsets.save_state.save_stateSaveState backed by one Redis key, save_state_redis_key
SerializeState, SerializeStateSlotsfastapi_viewsets.save_state.serialize_stateserialize_state() / deserialize_state(state); the second serialises the slots __slots__ names
NotFoundResponsefastapi_viewsets.response_classesThe documented model of a 404 body, {"detail": "Item with pk {pk} not found"}; NOT_FOUND_RESPONSE is the responses entry the mixins attach

Released under the MIT License.