In the context of a Google App Engine Webapp framework application:
I want to changed the request verb of a request in the case a parameter _method is provided, for example if a POST request comes in with a parameter _method=PUT, I need to change the request to call the put method of the handler. This is to cope with the way prototype.js works with verbs like PUT and DELETE(workaround for IE). Here is my first attempt:
class MyRequestHandler(webapp.RequestHandler): def initialize(self, request, response): m = request.get('_method') if m: request.method = m.upper() webapp.RequestHandler.initialize(self, request, response)
The problem is, for some reason whenever the redirect is done, the self.request.params are emptied by the time the handling method(put or delete) is called, even though they were populated when initialize was called. Anyone have a clue why this is? As a workaround I thought I could clone the params at initialize() time, but .copy() did not work, and I haven't found a way to do that either.
Update: I received a very helpful response from Arachnid. The solution I ended up with uses a metaclass. It is found below.