Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#16635 closed Bug (wontfix)

Wording in documentation for contrib.auth could be improved on is_anonymous()

Reported by: cyclops Owned by: nobody
Component: contrib.auth Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

https://docs.djangoproject.com/en/1.3/topics/auth/#django.contrib.auth.models.User.is_anonymous

starts with the text:

"Always returns False."

A better wording might be:

"Returns False if the user has not been authenticated, i.e., entered a valid login and password."

Change History (2)

comment:1 by anonymous, 13 years ago

Resolution: wontfix
Status: newclosed

The referenced doc is describing the methods implemented in the auth User class: https://code.djangoproject.com/browser/django/trunk/django/contrib/auth/models.py#L209

It's accurate as-is. The suggested re-wording implies you might have an auth User instance that would sometimes return True for is_anonymous, which is not the case. If you have a User, not an AnonymouseUser, it will always return False for is_anonymous. (The determination of whether the "requesting user" is authenticated or not is not done by the User class code but rather by other code that then constructs either a User or an AnonymousUser instance that is attached to a request object.)

is_anonymous (and is_authenticated) are there as convenience methods to allow you to call the same method on different types of user instances and get correct answers for each. They don't actually do any checking of anything, and to put in the docs anything other than that a User instance will return False for is_anonymous would be misleading, in my opinion.

comment:2 by Karen Tracey, 13 years ago

(That was me with the wontfix close.)

Note: See TracTickets for help on using tickets.
Back to Top