diff options
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/cgi.rst | 43 | ||||
-rw-r--r-- | Doc/library/urllib.rst | 2 | ||||
-rw-r--r-- | Doc/library/urlparse.rst | 39 |
3 files changed, 46 insertions, 38 deletions
diff --git a/Doc/library/cgi.rst b/Doc/library/cgi.rst index 17cd750..0248284 100644 --- a/Doc/library/cgi.rst +++ b/Doc/library/cgi.rst @@ -282,49 +282,18 @@ algorithms implemented in this module in other circumstances. Parse a query in the environment or from a file (the file defaults to ``sys.stdin``). The *keep_blank_values* and *strict_parsing* parameters are - passed to :func:`parse_qs` unchanged. + passed to :func:`urlparse.parse_qs` unchanged. .. function:: parse_qs(qs[, keep_blank_values[, strict_parsing]]) - Parse a query string given as a string argument (data of type - :mimetype:`application/x-www-form-urlencoded`). Data are returned as a - dictionary. The dictionary keys are the unique query variable names and the - values are lists of values for each name. - - The optional argument *keep_blank_values* is a flag indicating whether blank - values in URL encoded queries should be treated as blank strings. A true value - indicates that blanks should be retained as blank strings. The default false - value indicates that blank values are to be ignored and treated as if they were - not included. - - The optional argument *strict_parsing* is a flag indicating what to do with - parsing errors. If false (the default), errors are silently ignored. If true, - errors raise a :exc:`ValueError` exception. - - Use the :func:`urllib.urlencode` function to convert such dictionaries into - query strings. - + This function is deprecated in this module. Use :func:`urlparse.parse_qs` + instead. It is maintained here only for backward compatiblity. .. function:: parse_qsl(qs[, keep_blank_values[, strict_parsing]]) - Parse a query string given as a string argument (data of type - :mimetype:`application/x-www-form-urlencoded`). Data are returned as a list of - name, value pairs. - - The optional argument *keep_blank_values* is a flag indicating whether blank - values in URL encoded queries should be treated as blank strings. A true value - indicates that blanks should be retained as blank strings. The default false - value indicates that blank values are to be ignored and treated as if they were - not included. - - The optional argument *strict_parsing* is a flag indicating what to do with - parsing errors. If false (the default), errors are silently ignored. If true, - errors raise a :exc:`ValueError` exception. - - Use the :func:`urllib.urlencode` function to convert such lists of pairs into - query strings. - + This function is deprecated in this module. Use :func:`urlparse.parse_qsl` + instead. It is maintained here only for backward compatiblity. .. function:: parse_multipart(fp, pdict) @@ -332,7 +301,7 @@ algorithms implemented in this module in other circumstances. Arguments are *fp* for the input file and *pdict* for a dictionary containing other parameters in the :mailheader:`Content-Type` header. - Returns a dictionary just like :func:`parse_qs` keys are the field names, each + Returns a dictionary just like :func:`urlparse.parse_qs` keys are the field names, each value is a list of values for that field. This is easy to use but not much good if you are expecting megabytes to be uploaded --- in that case, use the :class:`FieldStorage` class instead which is much more flexible. diff --git a/Doc/library/urllib.rst b/Doc/library/urllib.rst index 15e0c7a..b2f96a1 100644 --- a/Doc/library/urllib.rst +++ b/Doc/library/urllib.rst @@ -242,7 +242,7 @@ Utility functions of the sequence. When a sequence of two-element tuples is used as the *query* argument, the first element of each tuple is a key and the second is a value. The order of parameters in the encoded string will match the order of parameter - tuples in the sequence. The :mod:`cgi` module provides the functions + tuples in the sequence. The :mod:`urlparse` module provides the functions :func:`parse_qs` and :func:`parse_qsl` which are used to parse query strings into Python data structures. diff --git a/Doc/library/urlparse.rst b/Doc/library/urlparse.rst index 02984f6..e7ed0f1 100644 --- a/Doc/library/urlparse.rst +++ b/Doc/library/urlparse.rst @@ -101,6 +101,45 @@ The :mod:`urlparse` module defines the following functions: .. versionchanged:: 2.5 Added attributes to return value. +.. function:: parse_qs(qs[, keep_blank_values[, strict_parsing]]) + + Parse a query string given as a string argument (data of type + :mimetype:`application/x-www-form-urlencoded`). Data are returned as a + dictionary. The dictionary keys are the unique query variable names and the + values are lists of values for each name. + + The optional argument *keep_blank_values* is a flag indicating whether blank + values in URL encoded queries should be treated as blank strings. A true value + indicates that blanks should be retained as blank strings. The default false + value indicates that blank values are to be ignored and treated as if they were + not included. + + The optional argument *strict_parsing* is a flag indicating what to do with + parsing errors. If false (the default), errors are silently ignored. If true, + errors raise a :exc:`ValueError` exception. + + Use the :func:`urllib.urlencode` function to convert such dictionaries into + query strings. + + +.. function:: parse_qsl(qs[, keep_blank_values[, strict_parsing]]) + + Parse a query string given as a string argument (data of type + :mimetype:`application/x-www-form-urlencoded`). Data are returned as a list of + name, value pairs. + + The optional argument *keep_blank_values* is a flag indicating whether blank + values in URL encoded queries should be treated as blank strings. A true value + indicates that blanks should be retained as blank strings. The default false + value indicates that blank values are to be ignored and treated as if they were + not included. + + The optional argument *strict_parsing* is a flag indicating what to do with + parsing errors. If false (the default), errors are silently ignored. If true, + errors raise a :exc:`ValueError` exception. + + Use the :func:`urllib.urlencode` function to convert such lists of pairs into + query strings. .. function:: urlunparse(parts) |