fix issue4333
This commit is contained in:
parent
86009452fb
commit
4fc54c8d5f
2 changed files with 10 additions and 1 deletions
|
|
@ -24,6 +24,8 @@ Released 2021-10-04
|
|||
- Fix the order of ``before_request`` and other callbacks that trigger
|
||||
before the view returns. They are called from the app down to the
|
||||
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
|
||||
|
|
|
|||
|
|
@ -130,7 +130,14 @@ def after_this_request(f: AfterRequestCallable) -> AfterRequestCallable:
|
|||
|
||||
.. versionadded:: 0.9
|
||||
"""
|
||||
_request_ctx_stack.top._after_request_functions.append(f)
|
||||
try:
|
||||
_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
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue