Opened 12 years ago

Closed 12 years ago

#2931 closed defect (fixed)

"if request.POST" should read "if request.method == 'POST'"

Reported by: davidschein@… Owned by: Jacob
Component: Documentation Version:
Severity: minor Keywords:
Cc: gary.wilson@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


we have:

It's possible that a request can come in via POST with an empty POST dictionary -- if, say, a form is requested via the POST HTTP method but does not include form data. Therefore, you shouldn't use if request.POST to check for use of the POST method; instead, use if request.method == "POST" (see above).

Then in
we violate that advice with:

def create_place(request):
    manipulator = Place.AddManipulator()

    if request.POST:

Change History (6)

comment:1 Changed 12 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [3914]) Fixed #2931 -- Use request.method == 'POST' where appropriate in the examples.
Thanks, David Schein.

comment:2 Changed 12 years ago by Gary Wilson <gary.wilson@…>

Resolution: fixed
Status: closedreopened

request.POST is used once elsewhere in the docs and several places in trunk too that maybe should be changed.

comment:3 Changed 12 years ago by Gary Wilson <gary.wilson@…>

Cc: gary.wilson@… added

comment:4 Changed 12 years ago by Bastian Kleineidam <calvin@…>

Hmm, should that be request.method.lower() == 'post' to be really sure? Just nitpicking, though.

comment:5 Changed 12 years ago by Chris Beaven

.lower() shouldn't be necessary: according to documentation, request.method will always return an uppercase value.

comment:6 Changed 12 years ago by Adrian Holovaty

Resolution: fixed
Status: reopenedclosed

(In [4110]) Fixed #2931 -- Changed 'if request.POST' to 'if request.method == POST' in docs/sessions.txt

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