forked from orbit-oss/flask
Fix registering a blueprint twice with differing names
Previously the blueprint recorded aspects (before request, after request etc) would only be added to the app if it was the first registration of the blueprint instance. However only the record-once aspects (app-before requests, app-after request) should be added once on registration of the instance, whereas everything else should be added on every unique name registration. This ensures that these trigger under the new name as well as the old.
This commit is contained in:
parent
399b851ed7
commit
a44c722860
3 changed files with 16 additions and 3 deletions
|
|
@ -899,6 +899,14 @@ def test_blueprint_renaming(app, client) -> None:
|
|||
def index():
|
||||
return flask.request.endpoint
|
||||
|
||||
@bp.get("/error")
|
||||
def error():
|
||||
flask.abort(403)
|
||||
|
||||
@bp.errorhandler(403)
|
||||
def forbidden(_: Exception):
|
||||
return "Error", 403
|
||||
|
||||
@bp2.get("/")
|
||||
def index2():
|
||||
return flask.request.endpoint
|
||||
|
|
@ -911,3 +919,5 @@ def test_blueprint_renaming(app, client) -> None:
|
|||
assert client.get("/b/").data == b"alt.index"
|
||||
assert client.get("/a/a/").data == b"bp.sub.index2"
|
||||
assert client.get("/b/a/").data == b"alt.sub.index2"
|
||||
assert client.get("/a/error").data == b"Error"
|
||||
assert client.get("/b/error").data == b"Error"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue