Or you can modify self
class MyRequestHandler(webapp.RequestHandler):
    def initialize(self, request, response):
        m = request.get('_method')
        if m:
            self.__dict__[request.method] =  self.__dict__[m]
        webapp.RequestHandler.initialize(self, request, response)


On Nov 3, 8:17 pm, Jeff S <[EMAIL PROTECTED]> wrote:
> Is there a reason why you can't call a different request handler
> method based on the request URL's _method parameter. For example, this
> seems like it would work:
>
> class MyRequestHandler(webapp.RequestHandler):
>
>   def post(self):
>     if self.request.get('_method') == 'PUT':
>       self.put()
>     else:
>       # Continue with an actual POST.
>
>   def put(self):
>     # Idempotent PUT logic.
>
> Happy coding,
>
> Jeff
>
> On Oct 31, 2:32 pm, airportyh <[EMAIL PROTECTED]> wrote:
>
> > 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 is
> > 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.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to