"In my experience the biggest benefit of class-based views are when you
are doing a bunch of similar stuff that's just a tiny bit different,
for which you can just subclass the view class for the bits you need
to change"

Yap ... that's exactly why I'm looking for a class-based views.

thank you
Daniel

On Mon, Jun 29, 2009 at 1:09 PM, Justin Lilly<justinli...@gmail.com> wrote:
>
> It's also worth noting that you _can_ use a class for a view. Views
> just have to be python callables. For more info on this, check out
> Marty Alchin's Pro Django and the python doc's for __call__.
>
> In my experience the biggest benefit of class-based views are when you
> are doing a bunch of similar stuff that's just a tiny bit different,
> for which you can just subclass the view class for the bits you need
> to change.
>
> Hope that helps.
>
>   -justin
>
>
>
> On Jun 29, 2009, at 6:28 AM, Raja <rajas...@gmail.com> wrote:
>
>>
>> You could use decorators (following the Decorator pattern) to do pre/
>> post interceptors. For e.g.
>> http://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.decorators.login_required
>> shows a login_required decorator to make sure that those views can
>> only be accessed after logging in.
>>
>> -- Raja
>>
>>
>> On Jun 29, 3:16 pm, Daniel Guryca <dun...@gmail.com> wrote:
>>> OK
>>> As I have said I'm coming from java so it's not so easy to change my
>>> mind to a totally different approach.
>>>
>>> But I'm still curious if there is any before or after interceptor
>>> in django.
>>> Or how to implement one using a django style.
>>>
>>> Thank you
>>> Daniel
>>>
>>> On Mon, Jun 29, 2009 at 12:05 PM, James
>>> Gregory<james....@gmail.com> wrote:
>>>
>>>> On Jun 29, 10:59 am, Daniel Guryca <dun...@gmail.com> wrote:
>>>>> Hi,
>>>
>>>>> I'm very new to django and python .. coming from java world.
>>>
>>>>> I really like django structure (apps, ...) but I do not
>>>>> understand how
>>>>> one can create some base class where all general methods same for
>>>>> all
>>>>> views could be put.
>>>>> You know I can see that views.py is only a module I would rather
>>>>> expect class in it and all methods part of this class. Then this
>>>>> class
>>>>> could extend my BaseViewClass.
>>>
>>>>> Is something like before and after interceptors possible in
>>>>> django ?
>>>>> Then I would not need any base class.
>>>
>>>>> Thank you.
>>>>> Cheers
>>>>> Daniel
>>>
>>>> A class is just a collection of methods and data. In Django views do
>>>> not have any data, because that is fetched from the model. So
>>>> where is
>>>> the advantage of having your methods part of a class rather than
>>>> just
>>>> functions which are part of the module? It would just mean you would
>>>> have to add one extra layer of indentation to everything. If you
>>>> want,
>>>> think of the views.py module as being a class with no data members.
>>>
>>>> James
>> >
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to