[Patches] [Patch #101120] add .get() to cgi.FieldStorage and cgi.FormContentDict
noreply@sourceforge.net
noreply@sourceforge.net
Wed, 16 Aug 2000 02:16:53 -0700
Patch #101120 has been updated.
Project:
Category: library
Status: Open
Summary: add .get() to cgi.FieldStorage and cgi.FormContentDict
Follow-Ups:
Date: 2000-Aug-08 13:28
By: ping
Comment:
This actually adds all of the auxiliary dictionary
methods to FormContentDict (e.g. copy, update) since
it makes FormContentDict derive from UserDict.
__version__ has been incremented to 2.3.
-------------------------------------------------------
Date: 2000-Aug-15 14:38
By: tim_one
Comment:
Ping, if you don't make this a full patch (i.e., including doc changes, and tests if at all possible) Soon, I have to Postpone it. Also please it assign it to someone capable of reviewing it (not me -- don't know anything about cgi).
-------------------------------------------------------
Date: 2000-Aug-15 23:36
By: tim_one
Comment:
Assigned to Barry (sorry, Barry!) for sanity-checking.
Ping pointed out in email that the module in question already documents that it "acts like a dict", and all the patch does is make that true in more cases.
Looks benign to me, but I've never used the module, so it could stand a quick scan from someone who isn't a total idiot. Jeremy is probably the most natural choice for looking at this, but he won't be useful to us again until just a few days before 2.0b1 is scheduled to ship. Don't want to wait that long.
-------------------------------------------------------
Date: 2000-Aug-15 23:41
By: tim_one
Comment:
Reassigned to Moshe, cuz Ping said he volunteered. Way to go, Moshe! If this release ever goes it, you'll be the only reason it does <wink>.
-------------------------------------------------------
Date: 2000-Aug-16 00:28
By: moshez
Comment:
OK, I gave it a short run around and it looked quite
all right. I do have on qualm, Ping: it's a bit awkward
to use .get() like that, because you still have to check
whether to use .value or not.
Here's an example of what I mean
(I hope if I surround it with PRE tags it will be protected):
<PRE>
print cgi.FieldStorage().get("hello",
cgi.MiniFieldStorage("hello", "world)).value
</PRE>
Because otherwise .get() doesn't buy you much. However,
other then that it's great -- accept that there still
aren't docos and test cases. (So I've kept this "Open")
-------------------------------------------------------
Date: 2000-Aug-16 02:16
By: ping
Comment:
Okay, here's the new patch. There is quite a bit more now:
1. Fixed parse_qsl to honour the keep_blank_values argument. Previously FieldStorage() would contain empty fields despite keep_blank_values being zero, contrary to intent. Now empty fields will not be present unless keep_blank_values is supplied. This could break code that expects fields to always be present, but it is also more in keeping with the way keep_blank_values was supposed to work. (If compatibility is enough of a concern, we can default keep_blank_values to 1 to maintain the old behaviour.)
2. New get() method on FieldStorage looks up the string value in the 'value' attribute. When a multiple values are present, it looks up the 'value' attribute within each MiniFieldStorage and produces a list of strings.
3. FormContentDict is derived from UserDict (same as the original patch).
4. More tests: new tests for FieldStorage, since there were none before, and tests for the get() method.
5. Documentation updates: describe the get() method, the keep_blank_values option, and simplify the examples with the convenient use of the get() method. Fix a little formatting. Standardize the capitalization of "Content-Type". Reword the descriptions of parse_multipart and parse_header to make them more comprehensible.
Phew.
-------------------------------------------------------
-------------------------------------------------------
For more info, visit:
http://sourceforge.net/patch/?func=detailpatch&patch_id=101120&group_id=5470