Opened 17 years ago

Closed 17 years ago

Last modified 17 years ago

#4675 closed (invalid)

Typo in view example in session.txt

Reported by: anhj@… 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)

comment:1 by Gary Wilson <gary.wilson@…>, 17 years ago

Resolution: invalid
Status: newclosed

No, it is correct. If the session does not have the "has_commented" key, then they have not posted a comment yet.

in reply to:  1 comment:2 by anhj@…, 17 years ago

Resolution: invalid
Status: closedreopened

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 :)

comment:3 by Gary Wilson <gary.wilson@…>, 17 years ago

Resolution: invalid
Status: reopenedclosed

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 is True => request.session.get('has_commented', False) evaluates to True => user sees "You've already commented."
  • has_commented is False => request.session.get('has_commented', False) evaluates to False => 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 to False => user's comment is saved and they see "Thanks for your comment!"

in reply to:  3 comment:4 by anonymous, 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 is True => request.session.get('has_commented', False) evaluates to True => user sees "You've already commented."
  • has_commented is False => request.session.get('has_commented', False) evaluates to False => 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 to False => user's comment is saved and they see "Thanks for your comment!"

Sorry, I definitely missed the point - thank you for the additional details.

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