I'm sometimes unsure how to use webapp2.redirect.
Is there ever a time when I should use
self.redirect("/blah")
instead of return self.redirect("/blah")
Here is my understanding/guess of the time-line: (sometimes i'm confused about if the response object does something or if webapp2 does it)
example of the initial get function:
def get():
self.write('hello world')
self.redirect('/foo')
self.write('bye world')
What "stuff happens"? I suppose the router finds /foo/'s RequestHandler. What modifications are made to the Request and Response before foo's requestHandlers get() method is called. Is the request deleted and replaced by a new GET request? Is the response deleted and replaced by a new one? What context remains that was present in the initial request handler? does code execution return to the initial request handlers get method and if so is the context that may have existed restored?
Sorry If this is a bit of a mouthful, I've tried explaining what I want to know :)
Perhaps it would have been easier to ask for some use cases (do's and don'ts) of using redirect instead.
The redirect method is really just some useful fluff around setting the response status and response Location header. Nothing really happens until the response is sent to the client which follows the redirect. You would want to return the result of calling redirect simply to avoid more code being run if there was more after the redirect that you didn't want run.
The source is quite easy to read.. http://webapp2.readthedocs.io/en/latest/_modules/webapp2.html#redirect