Package cherrypy :: Module _cperror :: Class HTTPRedirect
[hide private]
[frames] | no frames]

Class HTTPRedirect

source code

exceptions.Exception --+    
                       |    
       CherryPyException --+
                           |
                          HTTPRedirect

Exception raised when the request should be redirected.

The new URL must be passed as the first argument to the Exception, e.g., HTTPRedirect(newUrl). Multiple URLs are allowed. If a URL is absolute, it will be used as-is. If it is relative, it is assumed to be relative to the current cherrypy.request.path_info.

Instance Methods [hide private]
 
__init__(self, urls, status=None) source code
 
set_response(self)
Modify cherrypy.response status, headers, and body to represent self.
source code
 
__call__(self)
Use this exception as a request.handler (raise self).
source code

Inherited from exceptions.Exception: __getitem__, __str__

Method Details [hide private]

__init__(self, urls, status=None)
(Constructor)

source code 
Overrides: exceptions.Exception.__init__

set_response(self)

source code 

Modify cherrypy.response status, headers, and body to represent self.

CherryPy uses this internally, but you can also use it to create an HTTPRedirect object and set its output without *raising* the exception.