Issue #141 resolved

use cgi.parse_qs()

Anonymous avatarAnonymous created an issue

Per this [http://groups-beta.google.com/group/cherrypy-devel/browse_thread/thread/d1aecc21e331c48b?hl=en thread], I propose using cgi.parse_qs() rather than re-implementing it in _cphttptools.py.

Reported by michalg@gmail.com

Comments (8)

  1. Anonymous

    It occurs to me that cgi.parse_qs() introduces a potential incompatibility with the parsing mechanism currently implemented. cgi.parse_qs converts variable to a list of length 0, 1, or more.

    I hold a preference for this way of parsing. It makes code to handle input more robust and less obfuscated by conditionals that test if a value is a singleton string or a list of strings... it's simply always a list.

    What do people think?

  2. Anonymous

    As I found out (Ticket #142), you need to add a patch to the test suite, as well, specifically test/03_get_and_post.py

  3. Anonymous

    Ah, thanks for the work fumanchu.

    I'm actually in favor of modifying the behavior (or, at least making it a global switch in the server startup) so that it is like cgi.parse_qs(). It makes more sense to me that every variable's value is always a list, either of length 0, 1, or more. Rather than having extra code to test if it IS a list first.

    This favoring seems to have been echoed by at least one other -devel'er (alankila), at:

    http://groups-beta.google.com/group/cherrypy-devel/msg/2719f5c9dab66869?hl=en

    I'm also marking this as an "ehancement" rather than "normal". That seems to describe it better.

    -Michal

  4. Anonymous

    It makes more sense to me that every variable's value is always a list

    Perhaps, but that's an issue separate from this patch/ticket. ;) I think it's better to stick with the existing spec for now. We can get this accepted now and hash out the always-a-list option on the mailing list(s) later.

  5. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.