def redirect(uri, permanent=False, abort=False, code=None, body=None, request=None, response=None):
 if uri.startswith(('.', '/')):
  request = (request or get_request())
  uri = str(urlparse.urljoin(request.url, uri))
 if (code is None):
  if permanent:
   code = 301
  else:
   code = 302
 assert (code in (301, 302, 303, 305, 307)), 'Invalid redirect status code.'
 if abort:
  _abort(code, headers=[('Location', uri)])
 if (response is None):
  request = (request or get_request())
  response = request.app.response_class()
 else:
  response.clear()
 response.headers['Location'] = uri
 response.status = code
 if (body is not None):
  response.write(body)
 return response

def redirect ( uri , permanent = False , abort = False , code = None , body = None , request = None , response = None ) : if uri . startswith ( ( '.' , '/' ) ) : request = ( request or get_request ( ) ) uri = str ( urlparse . urljoin ( request . url , uri ) ) if ( code is None ) : if permanent : code = 301 else : code = 302 assert ( code in ( 301 , 302 , 303 , 305 , 307 ) ) , 'Invalid redirect status code.' if abort : _abort ( code , headers = [ ( 'Location' , uri ) ] ) if ( response is None ) : request = ( request or get_request ( ) ) response = request . app . response_class ( ) else : response . clear ( ) response . headers [ 'Location' ] = uri response . status = code if ( body is not None ) : response . write ( body ) return response
simple wrapper for httpresponseredirect that checks the request for a next get parameter then falls back to a given object or url string .