fix issue4333

This commit is contained in:
Rohan-Salwan 2021-11-11 17:15:00 +05:30
parent 86009452fb
commit 4fc54c8d5f
2 changed files with 10 additions and 1 deletions

View file

@ -24,6 +24,8 @@ Released 2021-10-04
- Fix the order of ``before_request`` and other callbacks that trigger - Fix the order of ``before_request`` and other callbacks that trigger
before the view returns. They are called from the app down to the before the view returns. They are called from the app down to the
closest nested blueprint. :issue:`4229` closest nested blueprint. :issue:`4229`
- Fix ``after_this_request`` fails with a meaningless error when used
outside request context. :issue:`4333`
Version 2.0.1 Version 2.0.1

View file

@ -130,7 +130,14 @@ def after_this_request(f: AfterRequestCallable) -> AfterRequestCallable:
.. versionadded:: 0.9 .. versionadded:: 0.9
""" """
try:
_request_ctx_stack.top._after_request_functions.append(f) _request_ctx_stack.top._after_request_functions.append(f)
except Exception:
print(
"This decorator can only be used at local scopes "
"when a request context is on the stack. For instance within "
"view functions."
)
return f return f