diff --git a/CHANGES.rst b/CHANGES.rst index 57dbf3dc14..f50a7ad90a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -27,6 +27,13 @@ Unreleased removed early. :issue:`4078` - Improve typing for some functions using ``Callable`` in their type signatures, focusing on decorator factories. :issue:`4060` +- Nested blueprints are registered with their dotted name. This allows + different blueprints with the same name to be nested at different + locations. :issue:`4069` +- ``register_blueprint`` takes a ``name`` option to change the + (pre-dotted) name the blueprint is registered with. This allows the + same blueprint to be registered multiple times with unique names for + ``url_for``. :issue:`1091` Version 2.0.0 diff --git a/src/flask/app.py b/src/flask/app.py index 315633b572..3abce3ce14 100644 --- a/src/flask/app.py +++ b/src/flask/app.py @@ -1019,6 +1019,12 @@ def register_blueprint(self, blueprint: "Blueprint", **options: t.Any) -> None: :class:`~flask.blueprints.BlueprintSetupState`. They can be accessed in :meth:`~flask.Blueprint.record` callbacks. + .. versionchanged:: 2.0.1 + The ``name`` option can be used to change the (pre-dotted) + name the blueprint is registered with. This allows the same + blueprint to be registered multiple times with unique names + for ``url_for``. + .. versionadded:: 0.7 """ blueprint.register(self, options) diff --git a/src/flask/blueprints.py b/src/flask/blueprints.py index 61b0ac6993..6b4e27149a 100644 --- a/src/flask/blueprints.py +++ b/src/flask/blueprints.py @@ -252,6 +252,12 @@ def register_blueprint(self, blueprint: "Blueprint", **options: t.Any) -> None: arguments passed to this method will override the defaults set on the blueprint. + .. versionchanged:: 2.0.1 + The ``name`` option can be used to change the (pre-dotted) + name the blueprint is registered with. This allows the same + blueprint to be registered multiple times with unique names + for ``url_for``. + .. versionadded:: 2.0 """ self._blueprints.append((blueprint, options)) @@ -266,6 +272,17 @@ def register(self, app: "Flask", options: dict) -> None: with. :param options: Keyword arguments forwarded from :meth:`~Flask.register_blueprint`. + + .. versionchanged:: 2.0.1 + Nested blueprints are registered with their dotted name. + This allows different blueprints with the same name to be + nested at different locations. + + .. versionchanged:: 2.0.1 + The ``name`` option can be used to change the (pre-dotted) + name the blueprint is registered with. This allows the same + blueprint to be registered multiple times with unique names + for ``url_for``. """ first_registration = True