Opened 8 years ago

Closed 8 years ago

#3952 closed (invalid)

Patch to add 'has_key' function to SessionWrapper

Reported by: Collin Grady <cgrady@…> Owned by: adrian
Component: Contrib apps Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The SessionWrapper supports many common dict functions such as .get, contains and others, but has_key seems to have been overlooked

Attachments (1)

session-has_key.patch (500 bytes) - added by Collin Grady <cgrady@…> 8 years ago.

Download all attachments as: .zip

Change History (3)

Changed 8 years ago by Collin Grady <cgrady@…>

comment:1 Changed 8 years ago by anonymous

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Use "in" to test for keys.

if "message" in request.session:
    do_something()

IIRC, has_key will be deprecated as of Python 2.6 and has been removed for Python 3000. The "k in dic" format is the preferred style for new code.

comment:2 Changed 8 years ago by Collin Grady <cgrady@…>

  • Resolution set to invalid
  • Status changed from new to closed

Ah, I wasn't aware it was going away.

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