#4675 closed (invalid)
Typo in view example in session.txt
Reported by: | Owned by: | Jacob | |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In session.txt, section 2 (Using sessions in views), 1st example, line 2-3 should be:
if request.session.get('has_commented', True):
return HttpResponse("You've already commented.")
instead of:
if request.session.get('has_commented', False):
return HttpResponse("You've already commented.")
Change History (4)
follow-up: 2 comment:1 by , 17 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 17 years ago
Resolution: | invalid |
---|---|
Status: | closed → reopened |
Replying to Gary Wilson <gary.wilson@gmail.com>:
No, it is correct. If the session does not have the "has_commented" key, then they have not posted a comment yet.
Then the HttpResponse shoud not be "You've already commented". Which it is (line 101). Thus my 1st report :)
follow-up: 4 comment:3 by , 17 years ago
Resolution: | → invalid |
---|---|
Status: | reopened → closed |
But when the has_commented
key doesn't exist, the then clause of the if statement is not executed...
looking at the three cases:
has_commented
isTrue
=>request.session.get('has_commented', False)
evaluates toTrue
=> user sees "You've already commented."has_commented
isFalse
=>request.session.get('has_commented', False)
evaluates toFalse
=> user's comment is saved and they see "Thanks for your comment!"has_commented
key doesn't exist in session =>request.session.get('has_commented', False)
evaluates toFalse
=> user's comment is saved and they see "Thanks for your comment!"
comment:4 by , 17 years ago
Replying to Gary Wilson <gary.wilson@gmail.com>:
But when the
has_commented
key doesn't exist, the then clause of the if statement is not executed...
looking at the three cases:
has_commented
isTrue
=>request.session.get('has_commented', False)
evaluates toTrue
=> user sees "You've already commented."has_commented
isFalse
=>request.session.get('has_commented', False)
evaluates toFalse
=> user's comment is saved and they see "Thanks for your comment!"has_commented
key doesn't exist in session =>request.session.get('has_commented', False)
evaluates toFalse
=> user's comment is saved and they see "Thanks for your comment!"
Sorry, I definitely missed the point - thank you for the additional details.
No, it is correct. If the session does not have the "has_commented" key, then they have not posted a comment yet.