On 4 October 2010 19:22, Jacob Kaplan-Moss <ja...@jacobian.org> wrote:
> On Mon, Oct 4, 2010 at 12:08 PM, Alex Gaynor <alex.gay...@gmail.com> wrote:
>> Given that the primary complain against the __new__ solution is that
>> it's unintuitive to Python programmers that instantiating their class
>> results in some other class, why not simply go with a more explicit
>> classmethod.  Simply used as:
>>
>> url("^articles/$", ArticlesView.dispatch).
>
> Interesting. So `View.dispatch` would look something like:
>
>   �...@classmethod
>    def dispatch(cls, request, *args, **kwargs):
>        instance = cls()
>        callback = getattr(instance, request.method.lower())
>        return callback(request, *args, **kwargs)
>
> (e.g. create an instance of `cls` then call `get`/`post`/etc. on it).
>
> Other than the slight cruftyness of `dispatch`, I quite like it. Seems
> it addresses most of the issues we've found so far. Doesn't solve the
> "pass configuration into __init__" idea, but frankly I didn't think
> much of that idea in the first place.
>
> To my eyes this is the best solution raised so far.
>

The only problem is decorators: You can't just simply apply
login_required() to the class or the dispatch() method.  Otherwise, I
like this approach.

-- 
Łukasz Rekucki

-- 
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.

Reply via email to