Re: New `pre_handler()` method on Class-Based Views

2016-04-06 Thread Diederik van der Boor
Too bad the issue was already closed.

I’ve added my 2 cents: 
https://github.com/django/django/pull/6416#issuecomment-206301186
I’d expect having a View.setup() method would simplify things for both simple 
use case and complex projects.

Best,
Diederik

> Op 5 apr. 2016, om 15:20 heeft Tim Graham  het volgende 
> geschreven:
> 
> See the discussion on the pull request: 
> https://github.com/django/django/pull/6416 
> 
> 
> Aymeric says, "The GCBV API is already widely criticized for being too 
> complicated. I think that adding one method to save one line of code is a bad 
> trade-off. I'm -1."
> 
> On Sunday, April 3, 2016 at 3:35:26 PM UTC-4, Ryan Hiebert wrote:
> I have taken to using a prepare method called from dispatch which takes the 
> request  args, and I use it primarily to resolve ids in the url to db 
> objects. This sounds like it fills a similar purpose.
> 
> Sent from my iPhone
> 
> On Apr 3, 2016, at 14:07, Pablo Recio  
> wrote:
> 
>> Hey there,
>> 
>> Wanted to share an idea I had during some discussions in DjangoCon EU. When 
>> using CBV, sometimes we have to replicate behaviour between different 
>> handlers. For instance setting up certain objects, extra user checks... 
>> Normally the way to achieve this is to override the `dispatch()`, but it's a 
>> bit error-prone and doesn't feel too clean sometimes.
>> 
>> So I wrote a little piece of code that adds a `pre_handler()` method that 
>> gets called before the handler method, whatever that is. Here is the code: 
>> https://github.com/pablorecio/django/tree/pre-handler-view-method 
>> , if it's 
>> something that would get merged I'll happily submit a PR.
>> 
>> Thanks!
>> Pablo Recio
>> 
>> 
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django developers (Contributions to Django itself)" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-develop...@googlegroups.com .
>> To post to this group, send email to django-d...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-developers 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-developers/df0c7703-b496-4bfa-ad31-68b35be482fa%40googlegroups.com
>>  
>> .
>> For more options, visit https://groups.google.com/d/optout 
>> .
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-developers+unsubscr...@googlegroups.com 
> .
> To post to this group, send email to django-developers@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/django-developers 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-developers/087bc5f9-6aed-4614-ba66-b40815405d2d%40googlegroups.com
>  
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/22D78BAF-81A1-45C8-A6FB-C2A8FC786491%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: New `pre_handler()` method on Class-Based Views

2016-04-05 Thread Tim Graham
See the discussion on the pull request: 
https://github.com/django/django/pull/6416

Aymeric says, "The GCBV API is already widely criticized for being too 
complicated. I think that adding one method to save one line of code is a 
bad trade-off. I'm -1."

On Sunday, April 3, 2016 at 3:35:26 PM UTC-4, Ryan Hiebert wrote:
>
> I have taken to using a prepare method called from dispatch which takes 
> the request  args, and I use it primarily to resolve ids in the url to db 
> objects. This sounds like it fills a similar purpose.
>
> Sent from my iPhone
>
> On Apr 3, 2016, at 14:07, Pablo Recio  > wrote:
>
> Hey there,
>
> Wanted to share an idea I had during some discussions in DjangoCon EU. 
> When using CBV, sometimes we have to replicate behaviour between different 
> handlers. For instance setting up certain objects, extra user checks... 
> Normally the way to achieve this is to override the `dispatch()`, but it's 
> a bit error-prone and doesn't feel too clean sometimes.
>
> So I wrote a little piece of code that adds a `pre_handler()` method that 
> gets called before the handler method, whatever that is. Here is the code: 
> https://github.com/pablorecio/django/tree/pre-handler-view-method, if 
> it's something that would get merged I'll happily submit a PR.
>
> Thanks!
> Pablo Recio
>
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-develop...@googlegroups.com .
> To post to this group, send email to django-d...@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-developers/df0c7703-b496-4bfa-ad31-68b35be482fa%40googlegroups.com
>  
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/087bc5f9-6aed-4614-ba66-b40815405d2d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


New `pre_handler()` method on Class-Based Views

2016-04-03 Thread Pablo Recio
Hey there,

Wanted to share an idea I had during some discussions in DjangoCon EU. When 
using CBV, sometimes we have to replicate behaviour between different 
handlers. For instance setting up certain objects, extra user checks... 
Normally the way to achieve this is to override the `dispatch()`, but it's 
a bit error-prone and doesn't feel too clean sometimes.

So I wrote a little piece of code that adds a `pre_handler()` method that 
gets called before the handler method, whatever that is. Here is the 
code: https://github.com/pablorecio/django/tree/pre-handler-view-method, if 
it's something that would get merged I'll happily submit a PR.

Thanks!
Pablo Recio


-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/df0c7703-b496-4bfa-ad31-68b35be482fa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.