setup method on registered blueprint is error
This commit is contained in:
parent
2a33c17854
commit
fc03d0dfab
2 changed files with 8 additions and 13 deletions
|
|
@ -20,6 +20,8 @@ Unreleased
|
||||||
- ``json_encoder`` and ``json_decoder`` attributes on app and blueprint, and the
|
- ``json_encoder`` and ``json_decoder`` attributes on app and blueprint, and the
|
||||||
corresponding ``json.JSONEncoder`` and ``JSONDecoder`` classes, are removed.
|
corresponding ``json.JSONEncoder`` and ``JSONDecoder`` classes, are removed.
|
||||||
- The ``json.htmlsafe_dumps`` and ``htmlsafe_dump`` functions are removed.
|
- The ``json.htmlsafe_dumps`` and ``htmlsafe_dump`` functions are removed.
|
||||||
|
- Calling setup methods on blueprints after registration is an error instead of a
|
||||||
|
warning. :pr:`4997`
|
||||||
|
|
||||||
- Importing ``escape`` and ``Markup`` from ``flask`` is deprecated. Import them
|
- Importing ``escape`` and ``Markup`` from ``flask`` is deprecated. Import them
|
||||||
directly from ``markupsafe`` instead. :pr:`4996`
|
directly from ``markupsafe`` instead. :pr:`4996`
|
||||||
|
|
|
||||||
|
|
@ -207,19 +207,12 @@ class Blueprint(Scaffold):
|
||||||
|
|
||||||
def _check_setup_finished(self, f_name: str) -> None:
|
def _check_setup_finished(self, f_name: str) -> None:
|
||||||
if self._got_registered_once:
|
if self._got_registered_once:
|
||||||
import warnings
|
raise AssertionError(
|
||||||
|
f"The setup method '{f_name}' can no longer be called on the blueprint"
|
||||||
warnings.warn(
|
f" '{self.name}'. It has already been registered at least once, any"
|
||||||
f"The setup method '{f_name}' can no longer be called on"
|
" changes will not be applied consistently.\n"
|
||||||
f" the blueprint '{self.name}'. It has already been"
|
"Make sure all imports, decorators, functions, etc. needed to set up"
|
||||||
" registered at least once, any changes will not be"
|
" the blueprint are done before registering it."
|
||||||
" applied consistently.\n"
|
|
||||||
"Make sure all imports, decorators, functions, etc."
|
|
||||||
" needed to set up the blueprint are done before"
|
|
||||||
" registering it.\n"
|
|
||||||
"This warning will become an exception in Flask 2.3.",
|
|
||||||
UserWarning,
|
|
||||||
stacklevel=3,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@setupmethod
|
@setupmethod
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue