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