Skip to content

Commit ca8e621

Browse files
authored
Merge pull request #4596 from pallets/url_for-template
use app.url_for as template global
2 parents 00e2aac + 69e2300 commit ca8e621

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Unreleased
88
- Add new customization points to the ``Flask`` app object for many
99
previously global behaviors.
1010

11+
- ``flask.url_for`` will call ``app.url_for``. :issue:`4568`
1112
- ``flask.abort`` will call ``app.aborter``.
1213
``Flask.aborter_class`` and ``Flask.make_aborter`` can be used
1314
to customize this aborter. :issue:`4567`

src/flask/app.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
from .helpers import get_flashed_messages
4646
from .helpers import get_load_dotenv
4747
from .helpers import locked_cached_property
48-
from .helpers import url_for
4948
from .json import jsonify
5049
from .logging import create_logger
5150
from .scaffold import _endpoint_from_view_func
@@ -439,6 +438,7 @@ def __init__(
439438
#: to raise HTTP errors, and can be called directly as well.
440439
#:
441440
#: .. versionadded:: 2.2
441+
#: Moved from ``flask.abort``, which calls this object.
442442
self.aborter = self.make_aborter()
443443

444444
#: A list of functions that are called by
@@ -727,7 +727,7 @@ def create_jinja_environment(self) -> Environment:
727727

728728
rv = self.jinja_environment(self, **options)
729729
rv.globals.update(
730-
url_for=url_for,
730+
url_for=self.url_for,
731731
get_flashed_messages=get_flashed_messages,
732732
config=self.config,
733733
# request, session and g are normally added with the
@@ -1798,6 +1798,7 @@ def redirect(self, location: str, code: int = 302) -> BaseResponse:
17981798
:param code: The status code for the redirect.
17991799
18001800
.. versionadded:: 2.2
1801+
Moved from ``flask.redirect``, which calls this method.
18011802
"""
18021803
return _wz_redirect(location, code=code, Response=self.response_class)
18031804

0 commit comments

Comments
 (0)