Hi all,

I've been interested in the idea of faking HTTP methods that
browsers/servers might not support like the rails people are doing in
1.2 so I've written a very minimal middleware to do this--if someone
else has done this already sorry for the repetition. (It does the
method faking using a post form with a <input type="hidden"
name="_method" value="PUT"/>)

{{{
class RestfulMiddleware(object):
        fakers = ['PUT','DELETE']
        
        def process_request(self, request):
                if request.method == 'POST':
                        if request.has_key('_method'):
                                if request.POST['_method'] in self.fakers:
                                        request.method = request.POST['_method']
                return None
}}}

That coupled with @require_http_methods seems to work well in my
minimal testing.

jesse

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to