Skip to content
Myr

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

3 files+17 added−11 removed

modified:src/flask/app.py+5 added-2 removed
1662 unmodified lines
16631664 def redirect(self, location: str, code: int = 302) -> BaseResponse:1665 """Create a redirect response object.16661667 :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.16691670 :param location: The URL to redirect to.1671 :param code: The status code for the redirect.16721673 .. versionadded:: 2.21674 """1675 return _wz_redirect(location, code=code, Response=self.response_class)1676
463 unmodified lines
modified:src/flask/helpers.py+4 added-2 removed
347 unmodified lines
348 location: str, code: int = 302, Response: t.Optional[t.Type["BaseResponse"]] = None349) -> "BaseResponse":350 """Create a redirect response object.351352 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`.355356 :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``.360361 .. 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 lines
modified:CHANGES.rst+8 added-7 removed
3 unmodified lines
4-------------56Unreleased78- 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.1011 - ``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`1516- Refactor ``register_error_handler`` to consolidate error checking.17 Rewrite some error messages to be more consistent. :issue:`4559`1819
1282 unmodified lines