Skip to main content

add_ctx

Wraps a function to ensure the current Flask application context is passed as the first positional argument if it is not already present.

def add_ctx(
f: F
) - > F

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

Parameters

NameTypeDescription
fFThe function to be decorated, which expects a Flask application context as one of its arguments.

Returns

TypeDescription
FA wrapped version of the original function that automatically injects the current application context if it is missing from the arguments.