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 into the index function ,and when a user visit the index
page , he will get it ,and no matter which page he visit , he will
also get this value . However  , the problem is , what if he firstly
visit one of the other article page , maybe he just get the url for
some page , so , he won't get the categories value , cause he didn't
visit the index page , am I right ?

Maybe Django should learn from other frameworks to get a action system
to handle this.

Indeed , I really need your help with this . Thanks

On Dec 1, 2:22 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> 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 to authenticate whether the
> > user is logged in every view functions and pass some parameters to
> > every views function .
>
> > Any suggestions ?
>
> You'll end up dispatching every URL to the same view and then
> essentially building your own dispatcher to further dispatch to the
> "real" view functions. Or attach a decorator to those views you want
> this to happen to.
>
> Because, the point is, you rarely want such a thing to run for *every*
> view function. In any significantly sized application, there is rarely
> common stuff that runs for every single view that cannot be done via
> middleware. You're already receiving a request object in your functions,
> you can pass in extra parameters through that (just like we do with
> request.session, etc).
>
> In other words, the functionality already exists. It's spelled slightly
> differently to other frameworks, but that's pretty normal -- everybody
> has slightly different ways of writing the same thing.
>
> The option you are looking for is middleware. If you don't want to use
> that, that's fine and writing a wrapper to make it all automatic is
> obviously possible. But it's not shipped with Django, since we already
> provide one way to achieve this functionality.
>
> Regards,
> Malcolm
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to