Skip to main content

add_ctx

A decorator that ensures the current Flask application context is passed as the first argument to the wrapped function if it is not already present.

def add_ctx(
f: Callable
) - > Callable

Ensures that the current Flask application context is passed as the first positional argument to the decorated function.

Parameters

NameTypeDescription
fCallableThe function to be decorated, which expects a Flask application context as its first positional argument.

Returns

TypeDescription
CallableA wrapped version of the original function that automatically injects the active AppContext if it is missing from the arguments.