I made a decorator that checks for _method query strings or POST
arguments and redirects to the appropriate request verb.  Check out
the methods_via_query_allowed decorator here:

http://github.com/DocSavage/bloog/tree/master/handlers/restful.py

It's use would be like so:

import restful
...
@restful.methods_via_query_allowed
    def post(self):
        pass

If the current request has a _method with an overriding http verb,
it'll re-route to the appropriate handler.

-Bill

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