forked from orbit-oss/flask
deprecate before_first_request
This commit is contained in:
parent
7a2d5fb6df
commit
96c97dec09
6 changed files with 66 additions and 33 deletions
|
|
@ -543,7 +543,20 @@ class Blueprint(Scaffold):
|
|||
) -> ft.BeforeFirstRequestCallable:
|
||||
"""Like :meth:`Flask.before_first_request`. Such a function is
|
||||
executed before the first request to the application.
|
||||
|
||||
.. deprecated:: 2.2
|
||||
Will be removed in Flask 2.3. Run setup code when creating
|
||||
the application instead.
|
||||
"""
|
||||
import warnings
|
||||
|
||||
warnings.warn(
|
||||
"'before_app_first_request' is deprecated and will be"
|
||||
" removed in Flask 2.3. Use 'record_once' instead to run"
|
||||
" setup code when registering the blueprint.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
self.record_once(lambda s: s.app.before_first_request_funcs.append(f))
|
||||
return f
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue