Re: Does Django have a function that can be called by every view function ?

2008-12-01 Thread David Shieh
Thank you , guys ~ Your help are really good for me ~ On Dec 1, 11:23 pm, Jon Loyens <[EMAIL PROTECTED]> wrote: > Another +1 for decorators.  In fact, the example David S uses > authentication and logins as an example of what he wants to do and its > already handled as a decorator thus giving

Re: Does Django have a function that can be called by every view function ?

2008-12-01 Thread Jon Loyens
Another +1 for decorators. In fact, the example David S uses authentication and logins as an example of what he wants to do and its already handled as a decorator thus giving him a decent pattern to follow. David S, I'd suggest you look up the @login_required decorator and even look through the

Re: Does Django have a function that can be called by every view function ?

2008-12-01 Thread martyn
David, +1 for decorator. That let you use it or not in each view. On Dec 1, 9:30 am, David Shieh <[EMAIL PROTECTED]> wrote: > Thanks , David Zhou , I will find some information for decorator > And also , I will surf for middleware . > > Thank you very much , Malcolm. > > On Dec 1, 3:55 pm,

Re: Does Django have a function that can be called by every view function ?

2008-12-01 Thread David Shieh
Thanks , David Zhou , I will find some information for decorator And also , I will surf for middleware . Thank you very much , Malcolm. On Dec 1, 3:55 pm, "David Zhou" <[EMAIL PROTECTED]> wrote: > On Mon, Dec 1, 2008 at 2:23 AM, David Shieh <[EMAIL PROTECTED]> wrote: > > I dont' know whether

Re: Does Django have a function that can be called by every view function ?

2008-11-30 Thread David Zhou
On Mon, Dec 1, 2008 at 2:23 AM, David Shieh <[EMAIL PROTECTED]> wrote: > I dont' know whether this make any sense . > Right now , I can't test it , but if django won't initiate the > views.py as a class , this method will make no sense. Why not write a decorator? --- David Zhou [EMAIL

Re: Does Django have a function that can be called by every view function ?

2008-11-30 Thread David Shieh
I have found a post in here : http://davyd.livejournal.com/262859.html this is the way this author resolves this problem. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group,

Re: Does Django have a function that can be called by every view function ?

2008-11-30 Thread David Shieh
No , not in that way. Let me show you some code #a.py class A: def __init__(self): #do somthing #views.py class B(A): def index(request): #do something else #urls.py (r'^$', 'site.app.views.index'), I dont' know whether this make any sense . Right now , I can't

Re: Does Django have a function that can be called by every view function ?

2008-11-30 Thread Malcolm Tredinnick
On Sun, 2008-11-30 at 22:46 -0800, David Shieh wrote: > yeah , I will consider about middleware , and I am also thinking about > write a class that contains the functions I need , and other funcions > just inherit it , will it work ? Since functions don't inherit from classes, your question

Re: Does Django have a function that can be called by every view function ?

2008-11-30 Thread David Shieh
yeah , I will consider about middleware , and I am also thinking about write a class that contains the functions I need , and other funcions just inherit it , will it work ? On Dec 1, 2:41 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Sun, 2008-11-30 at 22:35 -0800, David Shieh wrote: >

Re: Does Django have a function that can be called by every view function ?

2008-11-30 Thread Malcolm Tredinnick
On Sun, 2008-11-30 at 22:35 -0800, David Shieh wrote: > Hi , Malcolm, > > Now , I understand what you said.But using session means user must to > call a certain to set the session. I was using session as an *example*. It's something that, based on incoming request information, is run every

Re: Does Django have a function that can be called by every view function ?

2008-11-30 Thread David Shieh
Hi , Malcolm, Now , I understand what you said.But using session means user must to call a certain to set the session.I mean , for example , I am setting up a blog , and every page want to show the categories this blog have . If I write these categories as a session value , I have to write it

Re: Does Django have a function that can be called by every view function ?

2008-11-30 Thread Malcolm Tredinnick
On Sun, 2008-11-30 at 21:48 -0800, David Shieh wrote: > Thanks , Malcolm , > > I think your solution can resolve my problem.But does it a bit > complex ? > In fact , what I really want is a view function that will be called by > every view function. > i.e. , if I wrote an auth system , I need

Re: Does Django have a function that can be called by every view function ?

2008-11-30 Thread James Bennett
On Sun, Nov 30, 2008 at 11:48 PM, David Shieh <[EMAIL PROTECTED]> wrote: > I think your solution can resolve my problem.But does it a bit > complex ? > In fact , what I really want is a view function that will be called by > every view function. > i.e. , if I wrote an auth system , I need to

Re: Does Django have a function that can be called by every view function ?

2008-11-30 Thread David Shieh
Thanks , Malcolm , I think your solution can resolve my problem.But does it a bit complex ? In fact , what I really want is a view function that will be called by every view function. i.e. , if I wrote an auth system , I need to authenticate whether the user is logged in every view functions and

Re: Does Django have a function that can be called by every view function ?

2008-11-30 Thread Malcolm Tredinnick
On Sun, 2008-11-30 at 19:41 -0800, David Shieh wrote: [...] > I have searched for some information . I know that middleware can do > this , but what I really want is just a small function for this . A process_request() function in middleware can be as small as you like. Middleware provides the

Does Django have a function that can be called by every view function ?

2008-11-30 Thread David Shieh
I have used Django for several months , and it really attacts me . I love it. But when I use it more , I found a problem troubles me , that is , I can't find a way to make a function be called by every view function automatically . I used CakePHP , it have a function named beforeFilter() . It