From cdf3212a3b56c46653e68bb092af656a20c9224f Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Fri, 14 Nov 2008 15:29:25 +0000 Subject: Describe doing an HTTP redirect. --- docs/narr/views.rst | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'docs') diff --git a/docs/narr/views.rst b/docs/narr/views.rst index c35027eb9..2f9bb7ff3 100644 --- a/docs/narr/views.rst +++ b/docs/narr/views.rst @@ -351,3 +351,22 @@ returned to the client. See the :ref:`security_chapter` chapter to find out how to turn on a security policy. +Using a View to Do A HTTP Redirect +---------------------------------- + +You can issue an HTTP redirect from within a view by returning a +slightly different response. + +.. code-block:: python + :linenos: + + from webob.exc import HTTPFound + + def myview(context, request): + return HTTPFound(location='http://example.com') + +All exception types from the :mod:`webob.exc` module implement the +``IResponse`` interface; any can be returned as the response from a +view. See :term:`WebOb` for the documentation for this module; it +includes other response types for Unauthorized, etc. + -- cgit v1.2.3