Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#4675 closed (invalid)

Typo in view example in session.txt

Reported by: anhj@… Owned by: jacob
Component: Documentation Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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 follow-up: Changed 8 years ago by Gary Wilson <gary.wilson@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

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

comment:2 in reply to: ↑ 1 Changed 8 years ago by anhj@…

  • Resolution invalid deleted
  • Status changed from closed to 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 :)

comment:3 follow-up: Changed 8 years ago by Gary Wilson <gary.wilson@…>

  • Resolution set to invalid
  • Status changed from reopened to 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 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!"

comment:4 in reply to: ↑ 3 Changed 8 years ago by anonymous

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