Re: Extend URL resolver support for HTTP Methods / REST support

2006-09-24 Thread Russell Cloran
Hi, On 9/22/06, James Crasta <[EMAIL PROTECTED]> wrote: > First, we define a RestfulView base class, which leverages python's > __call__ functionality. And now for something completely different: A decorator! :P OK, but seriously, I quite like the idea of using decorators. Below is a completely

Re: Extend URL resolver support for HTTP Methods / REST support

2006-09-23 Thread [EMAIL PROTECTED]
Simon de Haan wrote: > 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 > [..] > I'd be interested in your ideas. The URL resolver could also try to fi

Re: Extend URL resolver support for HTTP Methods / REST support

2006-09-22 Thread Malcolm Tredinnick
On Fri, 2006-09-22 at 17:17 +, wes wrote: > I also prefer using a dispatcher in the view, its simple and flexible, > and still allows you to use things like the @login_required decorator > on your base view function. > > >I'm using that sort of view now > >in a couple of places where I'm supp

Re: Extend URL resolver support for HTTP Methods / REST support

2006-09-22 Thread James Crasta
> How are you accessing the request.PUT and request.DELETE? I would think > those have to be added to the HttpRequest object before you could use > them in the view. Actually, Django doesn't have any specific machinery for handling PUT and DELETE and even more esoteric ones like PROPGET, but it'l

Re: Extend URL resolver support for HTTP Methods / REST support

2006-09-22 Thread wes
I also prefer using a dispatcher in the view, its simple and flexible, and still allows you to use things like the @login_required decorator on your base view function. >I'm using that sort of view now >in a couple of places where I'm supporting POST, PUT, GET and DELETE all >on the same resource

Re: Extend URL resolver support for HTTP Methods / REST support

2006-09-22 Thread Slowness Chen
jango-developers@googlegroups.com Sent: Friday, September 22, 2006 3:15 PM Subject: Re: Extend URL resolver support for HTTP Methods / REST support Malcom, In the ticket you mentioned that it can be pretty easily done via a view dispatcher - could you elaborate more on this? I

Re: Extend URL resolver support for HTTP Methods / REST support

2006-09-22 Thread Simon de Haan
I like your idea! I'll try & put something together this weekend & see how it goes.Why are you prepending handle_ on the functions instead of just having them be get(), post() etc...?Why not put them in a list & check if they exist in that list?allowed_methods = ['get','post','put'...]and thenfor x

Re: Extend URL resolver support for HTTP Methods / REST support

2006-09-22 Thread James Crasta
I have an alternate suggestion, an expansion of malcomt's idea, rather than changing the machinery of the current url handlers, and which should work in your existing code. (note this is untested code, but I believe it should work, barring any syntactical errors.) First, we define a RestfulView

Re: Extend URL resolver support for HTTP Methods / REST support

2006-09-22 Thread Ned Batchelder
Malcolm Tredinnick wrote: On Fri, 2006-09-22 at 10:20 +0200, Simon de Haan wrote: Yeah I get it and agree with you. So your suggestion is to not implement this in the urlpatterns and introduce it as a dispatcher in the view? That what works now and it's the an accepted

Re: Extend URL resolver support for HTTP Methods / REST support

2006-09-22 Thread Malcolm Tredinnick
On Fri, 2006-09-22 at 10:20 +0200, Simon de Haan wrote: > Yeah I get it and agree with you. > > > So your suggestion is to not implement this in the urlpatterns and > introduce it as a dispatcher in the view? That what works now and it's the an accepted Python idiom for simulating a switch stat

Re: Extend URL resolver support for HTTP Methods / REST support

2006-09-22 Thread Simon de Haan
Yeah I get it and agree with you.So your suggestion is to not implement this in the urlpatterns and introduce it as a dispatcher in the view? Met vriendelijke groet,Simon de HaanEight Media[EMAIL PROTECTED]+31 (0)26 38 42 440 On Sep 22, 2006, at 10:01 AM, Malcolm Tredinnick wrote:On Fri, 2006-09-22

Re: Extend URL resolver support for HTTP Methods / REST support

2006-09-22 Thread limodou
On 9/22/06, Simon de Haan <[EMAIL PROTECTED]> wrote: > > Hi, > > Fair enough - you're free to discuss your ideas. > > For this thread, I'd prefer sticking to ideas on whether to implement the > HTTP methods in the urlresolver and if the idea is any good - how this could > be done. > > Right now th

Re: Extend URL resolver support for HTTP Methods / REST support

2006-09-22 Thread Malcolm Tredinnick
On Fri, 2006-09-22 at 08:51 +0200, Simon de Haan 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 implementatio

Re: Extend URL resolver support for HTTP Methods / REST support

2006-09-22 Thread Simon de Haan
Hi,Fair enough - you're free to discuss your ideas.For this thread, I'd prefer sticking to ideas on whether to implement the HTTP methods in the urlresolver and if the idea is any good - how this could be done.Right now the urlresolver works with strings or functions, not dictionaries. Adding dicti

Re: Extend URL resolver support for HTTP Methods / REST support

2006-09-22 Thread Malcolm Tredinnick
On Fri, 2006-09-22 at 15:18 +0800, limodou wrote: > On 9/22/06, Ahmad Alhashemi <[EMAIL PROTECTED]> wrote: > > > > +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 implementat

Re: Extend URL resolver support for HTTP Methods / REST support

2006-09-22 Thread Malcolm Tredinnick
On Fri, 2006-09-22 at 09:15 +0200, Simon de Haan wrote: > Malcom, > > > In the ticket you mentioned that it can be pretty easily done via a > view dispatcher - could you elaborate more on this? I'd be interested > as to how one would go about doing this. The URL dispatcher doesn't change from w

Re: Extend URL resolver support for HTTP Methods / REST support

2006-09-22 Thread limodou
On 9/22/06, Simon de Haan <[EMAIL PROTECTED]> wrote: > Hi Limodou, > > Not sure about your decorator idea, personally I think it goes beyond the > scope of the url's in general and django's urlpatterns and is quite view > specific. > > Any ideas about implementing the GET/POST/PUT/DELETE etc..? >

Re: Extend URL resolver support for HTTP Methods / REST support

2006-09-22 Thread Simon de Haan
Hi Limodou,Not sure about your decorator idea, personally I think it goes beyond the scope of the url's in general and django's urlpatterns and is quite view specific.Any ideas about implementing the GET/POST/PUT/DELETE etc..? Met vriendelijke groet,Simon de HaanEight Media[EMAIL PROTECTED]+31 (0)2

Re: Extend URL resolver support for HTTP Methods / REST support

2006-09-22 Thread limodou
On 9/22/06, Ahmad Alhashemi <[EMAIL PROTECTED]> wrote: > > +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, exc

Re: Extend URL resolver support for HTTP Methods / REST support

2006-09-22 Thread Simon de Haan
Malcom,In the ticket you mentioned that it can be pretty easily done via a view dispatcher - could you elaborate more on this? I'd be interested as to how one would go about doing this. Kind regards,Simon de HaanEight Media[EMAIL PROTECTED]+31 (0)26 38 42 440 On Sep 22, 2006, at 9:04 AM, Ahmad Alha

Re: Extend URL resolver support for HTTP Methods / REST support

2006-09-22 Thread Ahmad Alhashemi
+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

Extend URL resolver support for HTTP Methods / REST support

2006-09-21 Thread Simon de Haan
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