Search code examples
pythonwebapp2

is there a way to modify request parameters in webapp2


I have a webapp2 logout request handler like:

class EditorLogoutHandler(base.LogoutPage):
    def get(self):
        self.request.get('return_url')

I want to change the 'return_url' and call the inherited method in base.LogoutPage.

Is there a way to do it? I looked through the docs but can't find it.


Solution

  • The request attribute which is an instance of webapp2.Request subclasses webob.Request.

    This may not be a precise answer but webapp2.Request.get in turn calls webapp2.Request.get_all which checks the POST and GET params sent in the request.

    If updating return_url sent as a parameter in a HTTP GET request, you can write:

    class EditorLogoutHandler(base.LogoutPage):
        def get(self):
            self.request.GET.update({'return_url': 'my-shiny-new-url'})
            super(EditorLogoutHandler, self).get()