Re: Dogfood the new class-based views in contrib.syndication?

2012-05-03 Thread Russell Keith-Magee
On Thu, May 3, 2012 at 4:25 PM, Stephen Burrows wrote: > I was recently working with django's syndication framework, and noticed that > it felt clunky in a lot of ways. For example, I can only access the request > and the kwargs for the function during the get_object method; if I want to > do anyt

Dogfood the new class-based views in contrib.syndication?

2012-05-03 Thread Stephen Burrows
I was recently working with django's syndication framework, and noticed that it felt clunky in a lot of ways. For example, I can only access the request and the kwargs for the function during the get_object method; if I want to do anything more complicated with them - for example, say I want to

Re: #14512: Decorating class based views (was Re: new class based views)

2010-11-12 Thread Łukasz Rekucki
Taking my best guess I removed the attribute based method from my patch and uploaded a new one[1]. Would be good to know if there is something obviously broken about my patch. [1]: http://code.djangoproject.com/ticket/14512 Cheers, Łukasz Rekucki -- You received this message because you are sub

Re: #14512: Decorating class based views (was Re: new class based views)

2010-10-24 Thread Łukasz Rekucki
Hi, I just added a patch to this ticket. It includes 2 solutions: First one is an implementation of Luke's idea with a class attribute. You just define an sequence: class MyView(View): decorators = [login_required, never_cache] # MyView.as_view === login_required(never_cache(View.as_v

Re: #14512: Decorating class based views (was Re: new class based views)

2010-10-21 Thread Łukasz Rekucki
On 21 October 2010 16:53, Luke Plant wrote: > On Thu, 2010-10-21 at 15:02 +0200, Łukasz Rekucki wrote: > >> > Good catch!  The attached patch should fix it, but it feels a bit icky, >> > due to the double application of the decorator. Let me know if it solves >> > this problem for you, or if you c

Re: #14512: Decorating class based views (was Re: new class based views)

2010-10-21 Thread Luke Plant
On Thu, 2010-10-21 at 15:02 +0200, Łukasz Rekucki wrote: > > Good catch! The attached patch should fix it, but it feels a bit icky, > > due to the double application of the decorator. Let me know if it solves > > this problem for you, or if you can think of a better way to fix it. > > I does fel

Re: #14512: Decorating class based views (was Re: new class based views)

2010-10-21 Thread Łukasz Rekucki
On 21 October 2010 14:31, Luke Plant wrote: > On Thu, 2010-10-21 at 01:40 +0200, Łukasz Rekucki wrote: > >> On a related note, while writing a class_decorator() I noticed that >> method_decorator() doesn't work with decorators that set attributes on >> the view (like csrf_exempt). This is because

Re: #14512: Decorating class based views (was Re: new class based views)

2010-10-21 Thread Luke Plant
On Thu, 2010-10-21 at 01:40 +0200, Łukasz Rekucki wrote: > On a related note, while writing a class_decorator() I noticed that > method_decorator() doesn't work with decorators that set attributes on > the view (like csrf_exempt). This is because the decorator is invoked > on a closure inside _wra

Re: new class based views

2010-10-20 Thread Russell Keith-Magee
On Thu, Oct 21, 2010 at 1:42 AM, Luke Plant wrote: > On Wed, 2010-10-20 at 16:05 +0200, Łukasz Rekucki wrote: > >> OTOH, it's annoying to have to write an dispatch() method with a super >> inside (which effectively does nothing), just to apply a decorator. > > That's a good point I hadn't thought

#14512: Decorating class based views (was Re: new class based views)

2010-10-20 Thread Łukasz Rekucki
On 20 October 2010 19:42, Luke Plant wrote: > On Wed, 2010-10-20 at 16:05 +0200, Łukasz Rekucki wrote: > >> OTOH, it's annoying to have to write an dispatch() method with a super >> inside (which effectively does nothing), just to apply a decorator. > > That's a good point I hadn't thought of, as

Re: new class based views

2010-10-20 Thread Luke Plant
On Wed, 2010-10-20 at 16:05 +0200, Łukasz Rekucki wrote: > OTOH, it's annoying to have to write an dispatch() method with a super > inside (which effectively does nothing), just to apply a decorator. That's a good point I hadn't thought of, as are Russell's other points. Just to put it on the ta

Re: new class based views

2010-10-20 Thread Łukasz Rekucki
Created a ticket for this: http://code.djangoproject.com/ticket/14512 On 20 October 2010 16:13, Russell Keith-Magee wrote: > On Wed, Oct 20, 2010 at 9:59 PM, Luke Plant wrote: >> On Wed, 2010-10-20 at 19:25 +0800, Russell Keith-Magee wrote: >> >>> A class decorator (and/or a wrapper function for

Re: new class based views

2010-10-20 Thread Russell Keith-Magee
On Wed, Oct 20, 2010 at 9:59 PM, Luke Plant wrote: > On Wed, 2010-10-20 at 19:25 +0800, Russell Keith-Magee wrote: > >> A class decorator (and/or a wrapper function for turning decorators >> into class decorators) is also an interesting idea. > > An argument against this is "one way to do it".  If

Re: new class based views

2010-10-20 Thread Valentin Golev
Well, since we are already using class Mixins for extending View functionality, we can try to turn decorators into mixins. Having two ways to add some functionality to class (decorators and mixins) can be somewhat uncomfortable. I had some doubts if mixins can act as a "wrappers" to defined functi

Re: new class based views

2010-10-20 Thread Łukasz Rekucki
On 20 October 2010 15:59, Luke Plant wrote: > On Wed, 2010-10-20 at 19:25 +0800, Russell Keith-Magee wrote: > >> A class decorator (and/or a wrapper function for turning decorators >> into class decorators) is also an interesting idea. > > An argument against this is "one way to do it".  If I look

Re: new class based views

2010-10-20 Thread Luke Plant
On Wed, 2010-10-20 at 19:25 +0800, Russell Keith-Magee wrote: > A class decorator (and/or a wrapper function for turning decorators > into class decorators) is also an interesting idea. An argument against this is "one way to do it". If I look at a class and want to know what decorators are app

Re: new class based views

2010-10-20 Thread Valentin Golev
I think class decorator for views only is a great idea, because it will be: a) just like with old view functions decorators b) does not require any method overrides/imports into urls.py/explicit transformations in views.py I'd like Django to have a decorator for turning old decorators into decora

Re: new class based views

2010-10-20 Thread Russell Keith-Magee
On Wed, Oct 20, 2010 at 7:05 PM, Valentin Golev wrote: > As far as I know, I can just say: > > @login_required > class MyView(View): >   # ... > > since it will wrap __init__ > > I need either to create a decorator for decorators: > @on_dispatch(login_required) > class MyView(View): > > or decorat

Re: new class based views

2010-10-20 Thread Valentin Golev
Almost everything I'm talking about right now is from this thread: http://groups.google.com/group/django-users/browse_frm/thread/5239e284b5c285d5/a2676f257d37cf85#a2676f257d37cf85 ("login_required and new class based views" in django-users in case the link doesnt work.)

Re: new class based views

2010-10-20 Thread Valentin Golev
As far as I know, I can just say: @login_required class MyView(View): # ... since it will wrap __init__ I need either to create a decorator for decorators: @on_dispatch(login_required) class MyView(View): or decorate result of MyView().as_view(). Maybe I'm wrong. I think it will be great to

Re: new class based views

2010-10-20 Thread Russell Keith-Magee
On Wed, Oct 20, 2010 at 6:01 PM, Valentin Golev wrote: > Awesome, thank you! > > I've asked about @login_required and class based views in > django-users, and I'd like to ask here: are something like > LoginRequiredMixin's planned? No, nothing like that is planned. This is a situation were decora

Re: new class based views

2010-10-20 Thread Valentin Golev
ble 12:00-18:00 MSK On Wed, Oct 20, 2010 at 4:36 AM, Russell Keith-Magee wrote: > On Wed, Oct 20, 2010 at 1:25 AM, Valentin Golev wrote: >> Hello, >> >> I'm trying to use brand new Class Based Views and I have a question >> about implementation. >> >> L

Re: new class based views

2010-10-19 Thread Russell Keith-Magee
On Wed, Oct 20, 2010 at 1:25 AM, Valentin Golev wrote: > Hello, > > I'm trying to use brand new Class Based Views and I have a question > about implementation. > > Let's take a look at SingleObjectMixin.get_object(): > http://code.djangoproject.com/browser/dj

Re: ,new class based views

2010-10-19 Thread Valentin Golev
Sorry! I've hit "Enter" key accidentally while writing a subject. Don't blame me too much, please :) On 19 окт, 21:22, Valentin Golev wrote: > Hello -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to djan

new class based views

2010-10-19 Thread Valentin Golev
Hello, I'm trying to use brand new Class Based Views and I have a question about implementation. Let's take a look at SingleObjectMixin.get_object(): http://code.djangoproject.com/browser/django/trunk/django/views/generic/detail.py Why does it use function arguments, and not self.kwa

,new class based views

2010-10-19 Thread Valentin Golev
Hello -- 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,

,new class based views

2010-10-19 Thread Valentin Golev
Hello -- 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,