#21595: Automatically call as_view() when urlpatterns encounter a CBV.
-------------------------------------+-------------------------------------
     Reporter:  loic84               |                    Owner:
         Type:                       |                   Status:  closed
  Cleanup/optimization               |                  Version:  master
    Component:  Core (URLs)          |               Resolution:  wontfix
     Severity:  Normal               |             Triage Stage:
     Keywords:                       |  Unreviewed
    Has patch:  1                    |      Needs documentation:  1
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Gwildor):

 I'm sorry for commenting on a closed ticket, but I can't seem to find a
 new ticket for this subject. Has a new ticket been opened yet?

 My quick two cents on this subject: perhaps with the eye on the future the
 way the CBV's work should be changed, which I think is a backwards
 compatible change. At the moment, the CBV's actually function as FBV's in
 the urls, because the {{{as_view()}}} method, as the name states, returns
 a function which is ''then'' called with the url dispatching. My proposal:
 when url dispatching happens, call it as a FBV when it's a view (this way
 FBV's and CBV.as_view() are both still supported as they should). If it's
 a class, initialize and call {{{dispatch()}}} on it ({{{__init__}}} should
 probably be rewritten for this, maybe dispatch can be called directly from
 the {{{__init__}}} if it's a class). If it's a class ''instance'', call
 {{{dispatch()}}} on it. This way, you can still pass {{{initkwargs}}} to
 the CBV in the urls, but the whole thing is more clear and generally makes
 more sense in my opinion. Python's {{{inspect}}} module can help with
 these things to check whether it's a function, a class or a class
 instance. A {{{__call___}}} method on the {{{View}}} class might also come
 in handy here.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/21595#comment:9>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.c2d3bb668546fb53e0236aae9076b1a2%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to