Opened 13 years ago
Closed 13 years ago
#16581 closed Cleanup/optimization (fixed)
Documentation of HttpRequest.META could note possibly surprising type values
Reported by: | Roy Smith | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | 1.3 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
HttpRequest.METASERVER_PORT, returns a string (i.e. "80"). It really should be an integer.
Some argument could be made that it really *should* be a string (see http://tinyurl.com/3fpb6px). If it is decided that string is correct, then at least it should be clearly documented. I think most people would expect a network port to be an integer.
Attachments (1)
Change History (7)
comment:1 by , 13 years ago
Component: | HTTP handling → Documentation |
---|---|
Summary: | HttpRequest.META['SERVER_PORT'] should be an integer → Documentation of HttpRequest.META could note possibly surprising type values |
Triage Stage: | Unreviewed → Accepted |
Type: | Bug → Cleanup/optimization |
comment:2 by , 13 years ago
Since this appears to be an intentional decision, and changing it would break backwards compatibility, I agree that documenting this (and CONTENT_LENGTH, and any others) would be a sufficient fix.
by , 13 years ago
Attachment: | 16581.diff added |
---|
comment:3 by , 13 years ago
Has patch: | set |
---|
I added a patch with warning signs :).
I've also changed the description of the other keys a bit.
comment:5 by , 13 years ago
Out of deference to people who have English as a second (or third or seventeenth) language, I'm going to leave most of these changes as they currently are. My understanding (from doing a internationalisation support for most of a decade) is that possessive form constructions are harder to unambiguously understand than the slightly more passive phrasing we have here. It's a bit of a judgement call, I'll admit.
Will commit the additions for LENGTH, TYPE, etc, though.
SERVER_PORT is coming from the underlying (or copied in, for older Django) Python wsgiref implementation (see http://hg.python.org/cpython/file/532cad687332/Lib/wsgiref/simple_server.py#l56). Note CONTENT_LENGTH is also a string value. I don't believe Django should change either of these, but if someone wants to provide a doc patch that notes that these values in
Request.META
are strings I suppose that might avoid some confusion for some people.