Backends reference#
Module summary#
next.backends holds the shared loading and lazy management helpers behind every settings-driven backend family.
load_backends instantiates a configured backend list, resolve_backend_class resolves one dotted BACKEND path against a family root, and SingleBackendManager lazily builds the single backend named by one settings key.
BackendRoot is the type alias each family uses to pass its abstract root class to these helpers.
The two loading paths differ in how they treat a misconfigured entry.
load_backends logs and skips it, so the family keeps serving with the remaining backends.
SingleBackendManager raises ImproperlyConfigured instead, because a family with one backend has nothing to fall back to.
Public API#
- next.backends.load_backends(configs: Iterable[Mapping[str, Any]], *, base: BackendRoot, default: str | None = None, signal: Signal | None = None) list[T][source]#
Instantiate every configured backend, skipping the misconfigured entries.
An entry is misconfigured when its dotted path does not resolve into the family, or when the backend itself answers ImproperlyConfigured. Such an entry costs its own backend and nothing else, so a site keeps serving with the rest. Anything else a constructor raises is a bug in that backend and reaches the caller.
- next.backends.resolve_backend_class(config: Mapping[str, Any], *, base: BackendRoot, default: str | None = None) type[T][source]#
Return the class named by config[‘BACKEND’], checked against base.
- class next.backends.SingleBackendManager(setting: str, *, base: BackendRoot, default: str | None = None)[source]#
Instantiates the single backend named by one framework settings key.
A misconfigured entry raises out of get() rather than being logged and skipped, because a family with one backend has nothing to fall back to.
- next.backends.BackendRoot = BackendRoot#
Type alias.
Type aliases are created through the type statement:
type Alias = intIn this example, Alias and int will be treated equivalently by static type checkers.
At runtime, Alias is an instance of TypeAliasType. The __name__ attribute holds the name of the type alias. The value of the type alias is stored in the __value__ attribute. It is evaluated lazily, so the value is computed only if the attribute is accessed.
Type aliases can also be generic:
type ListOrSet[T] = list[T] | set[T]In this case, the type parameters of the alias are stored in the __type_params__ attribute.
See PEP 695 for more information.