Opened 17 years ago

Closed 17 years ago

#3952 closed (invalid)

Patch to add 'has_key' function to SessionWrapper

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

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@…> 17 years ago.

Download all attachments as: .zip

Change History (3)

by Collin Grady <cgrady@…>, 17 years ago

Attachment: session-has_key.patch added

comment:1 by anonymous, 17 years ago

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 by Collin Grady <cgrady@…>, 17 years ago

Resolution: invalid
Status: newclosed

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

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