+1 on the idea. It is starting to make less and less sense to treat a GET and a POST the same way just because they use the same URL.
I don't think the implementation is ugly, either. I can't see how it can be made cleaner, except for using constants instead of strings for GET, POST, ..etc. But then again, we are probably getting those as strings from the backends. --Ahmad On 9/22/06, Simon de Haan <[EMAIL PROTECTED]> wrote: > > Hello everyone, > > I've posted a patch in trac which will allow the urlresolver to > select a view depending on the HTTP method (GET,POST,PUT,DELETE, etc..) > Its posted at http://code.djangoproject.com/ticket/2784 > > My implementation has been hacked together in a few minutes and isn't > pretty by any standards but Malcom suggested I pitch it here to start > a bit of a discussion. > > The urlpatters could then look like this: > > from django.conf.urls.defaults import * > > urlpatterns = patterns('', > # Example: > (r'^django_rest_urls/get/(?P<id>\d+)', > 'django_rest_urls.restful.views.get'), > (r'^django_rest_urls/(?P<id>\d+)', { > > 'GET': 'django_rest_urls.restful.views.get', > > 'POST': 'django_rest_urls.restful.views.post', > > 'PUT': 'django_rest_urls.restful.views.put', > > 'DELETE': 'django_rest_urls.restful.views.delete', > > }), > > # Uncomment this for admin: > # (r'^admin/', include('django.contrib.admin.urls')), > ) > > I like the idea of allowing the methods specify the view, in certain > situations it can be cleaner than using "if request.POST" type of > stuff in the view and will make RESTful type of applications easier > to build using Django. I guess it could be beneficial for AJAX type > of backends too. > > I'd be interested in your ideas. > > > Kind regards, > > Simon de Haan > > Eight Media > [EMAIL PROTECTED] > +31 (0)26 38 42 440 > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" 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-developers -~----------~----~----~----~------~----~------~--~---
