On Oct 4, 9:16 pm, Luke Plant <l.plant...@cantab.net> wrote: > On Mon, 2010-10-04 at 13:08 -0400, Alex Gaynor wrote: > > Last idea, I swear, > > I didn't swear, so here is another slight variation :-) You actually > *call* the classmethod in your URLconf, passing any constructor > arguments to it: > > url(r'^detail/author/(?P<pk>\d+)/$', > views.AuthorDetail.as_view(some_param=123), > name="author_detail"), > > It returns a newly created view function, which in turn calls your > class. > > http://bitbucket.org/spookylukey/django-class-views-experiments/src/t...
It seems there is a corollary to D. Wheeler's quote: "all problems in computer science can be solved by another level of nested closures" ;-) > This was, in fact, suggested by Jari Pennanen in May :-( > > http://groups.google.com/group/django-developers/msg/997ac5d38a96a27b > > It's slightly less verbose for passing parameters, as you don't need a > separate 'configure' call. Indeed, although it's very slightly more verbose for the (common) case that you don't want to pass parameters: views.AuthorDetail.as_view(). Unless we "cheat" and have the resolver do: if isinstance(view, type) and issubclass(view, View): # or perhaps if it quacks like a View # if hasattr(view, 'as_view'): view = view.as_view() in which case it can be declared in the urlconf simply as views.AuthorDetail. George -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.