update app.redirect docs
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Lord · committed by David Lord · parent 5512a66 · Browse files · 3 files·+17 added−11 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+17 added−11 removed
- other:+17 added−11 removed
Provenance
- Commit
fac6303- Tree
04ab866- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent
5512a66
3 files changed+17 added−11 removed
modified:src/flask/app.py+5 added-2 removed
1662 unmodified lines1663 1664 def redirect(self, location: str, code: int = 302) -> BaseResponse:1665 """Create a redirect response object.1666 1667- :param location: the url of the redirect1668- :param code: http return code1667+ This is called by :func:`flask.redirect`, and can be called1668+ directly as well.1669 1670+ :param location: The URL to redirect to.1671+ :param code: The status code for the redirect.1672+1673 .. versionadded:: 2.21674 """1675 return _wz_redirect(location, code=code, Response=self.response_class)1676 463 unmodified linesmodified:src/flask/helpers.py+4 added-2 removed
347 unmodified lines348 location: str, code: int = 302, Response: t.Optional[t.Type["BaseResponse"]] = None349 ) -> "BaseResponse":350 """Create a redirect response object.351 352- If :data:`~flask.current_app` is available, it will use353- :meth:`~flask.app.Flask.redirect`, otherwise it will use352+ If :data:`~flask.current_app` is available, it will use its353+ :meth:`~flask.Flask.redirect` method, otherwise it will use354 :func:`werkzeug.utils.redirect`.355 356 :param location: The URL to redirect to.357 :param code: The status code for the redirect.358 :param Response: The response class to use. Not used when359 ``current_app`` is active, which uses ``app.response_class``.360 361 .. versionadded:: 2.2362+ Calls ``current_app.redirect`` if available instead of always363+ using Werkzeug's default ``redirect``.364 """365 if current_app:366 return current_app.redirect(location, code=code)367 476 unmodified linesmodified:CHANGES.rst+8 added-7 removed
3 unmodified lines4 -------------5 6 Unreleased7 8-- Add ``aborter_class`` and ``aborter`` attributes to the Flask app9- object. ``flask.abort`` will call ``app.aborter``. This makes it10- possible for an app to override how aborts work, including custom11- status codes. :issue:`4567`12-- Add an ``app.redirect`` method, which ``flask.redirect`` will call.13- This makes it possible for an app to override how redirects work.14- :issue:`4569`8+- Add new customization points to the ``Flask`` app object for many9+ previously global behaviors.10+11+ - ``flask.abort`` will call ``app.aborter``.12+ ``Flask.aborter_class`` and ``Flask.make_aborter`` can be used13+ to customize this aborter. :issue:`4567`14+ - ``flask.redirect`` will call ``app.redirect``. :issue:`4569`15+16 - Refactor ``register_error_handler`` to consolidate error checking.17 Rewrite some error messages to be more consistent. :issue:`4559`18 19 1282 unmodified lines