#15645: HTTP methods in urls.py
-------------------------------------+-------------------------------------
               Reporter:  haras      |        Owner:  nobody
                 Status:  new        |    Milestone:
              Component:  HTTP       |      Version:
  handling                           |     Keywords:  http urls
             Resolution:             |    Has patch:  0
           Triage Stage:  Design     |  Needs tests:  0
  decision needed                    |
    Needs documentation:  0          |
Patch needs improvement:  0          |
-------------------------------------+-------------------------------------

Comment (by haras):

 Class Based Views View.dsipatch does not provide such clear and intuitive
 way of defining urls.
 And require an application to run view to check if it able to handle a
 request.
 IMHO this way gives you better scalability performance and easy of use.

 Look at those sample code (I am thinking about last one), and you know
 already which view is when executed, without having to see the inner code
 of any classes and views.
 When you look at somebody's else project you are not hoping to read views
 to see how one url is handled.
 When request is POST it looks up in POST urls and quickly omit not fitting
 GET and DELETE methods.

 My function views are full of those ifs:

 {{{
 if request.is_ajax:
   #do stuff
 else:
   if request.method == "POST":
      #do something
    else:
      #do else
 }}}

 Hence my true code is almost two indents inside those boilerplate if
 structure.
 Which is always the same... it takes a lot of python beauty and
 readibility from code.

 I know I am able to do

 {{{
 urlpatterns = patterns('myapp',
   url (r'/ajax/user/(?P<username>\d+)', 'views.myview'),
   url (r'/post/user/(?P<username>\d+)', 'views.myview'),
   url (r'/get/user/(?P<username>\d+)', 'views.myview'),
   url (r'/delete/user/(?P<username>\d+)', 'views.myview'),
 )
 }}}

 but what with reusability?

 We have to change this to something like r'/user/post/...' and
 r'/user/get/...'
 When first part of url determines app the second will have to be a
 method... and so on.
 Every django setup has completely different approach to handle urls.
 Therefore I think that this standardization I mention in my second post
 will solve problem, at least will provide a reasonable and logic way do
 define urls.

 Everywhere when I am looking for, people is talking about distinguishing
 methods inside view in nested ifs... I find it ugly, and necessary. IMHO
 urls dispatcher (the name dispatcher defines it!) should do this stuff.
 Not some kind of inner class based views magic. I think that magic belongs
 to ruby and RoR, and explicit is the true pythonic way.

 BTW. How this dispatch method got inside class based views?
 Isn't it suppose to be in some kind of dispatcher in modules? IMHO its
 logically do not fit to the Class Based Views.

 What do you think?

-- 
Ticket URL: <http://code.djangoproject.com/ticket/15645#comment:5>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" 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-updates?hl=en.

Reply via email to