What if we instead make it so that context_processor.auth only sets the
"user" template variable if request.user is not an AnonymousUser
instance and then in templates you would use

{% if user %}
I am logged in.
{% endif %}

to determine if the user is logged in.  If the user is not logged in,
then the "user" template variable will not get set and then the above
would evaluate to False.

I also got to thinking about the AuthenticationMiddleware setting
request.user to None instead of an AnonymousUser object (and doing away
with the AnonymousUser class) when the user is not logged in; however,
in views and code it is probably nice to be able to things like
request.user.has_perm('myperm') without having to put an "if user:"
check before it all the time.

But in the templates, this is not the case because you can do {% if
user.has_perm('myperm') %} without doing an {% if user %} check since
the "user" template variable wouldn't exist and would evaluate to False.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@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-developers
-~----------~----~----~----~------~----~------~--~---

Reply via email to