[Python-Dev] [RFC] urlparse - parse query facility
O.R.Senthil Kumaran
orsenthil at users.sourceforge.net
Sat Jun 16 10:41:01 CEST 2007
* Fred L. Drake, Jr. <fdrake at acm.org> [2007-06-16 01:06:59]:
> > * Coding question: Without retyping the bunch of code again in the
> > BaseResult, would is the possible to call parse_qs/parse_qsl function on
> > self.query and provide the result? Basically, what would be a good of
> > doing it.
>
> That's what I was thinking. Just add something like this to BaseResult
> (untested):
>
> def parsedQuery(self, keep_blank_values=False, strict_parsing=False):
> return parse_qs(
> self.query,
> keep_blank_values=keep_blank_values,
> strict_parsing=strict_parsing)
>
> def parsedQueryList(self, keep_blank_values=False, strict_parsing=False):
> return parse_qsl(
> self.query,
> keep_blank_values=keep_blank_values,
> strict_parsing=strict_parsing)
Thanks Fred. That really helped. :-)
I have updated the urlparse.py module, cgi.py and also included in the tests
in the test_urlparse.py to test this new functionality.
test run passed for all the valid queries, except for these:
# ("=", {}),
# ("=&=", {}),
# ("=;=", {}),
The testcases are basically from test_cgi.py module and there is comment on
validity of these 3 tests for query values.
Pending stuff is updating the documentation.
I maintained all the files temporarily at:
http://cvs.sarovar.org/cgi-bin/cvsweb.cgi/python/?cvsroot=uthcode
I had requested a commit access to Summer of Code branch in my previous mail,
but I guess it not been noticed yet. I shall update the files later or
send in as patches for application.
> Whether there's a real win with this is unclear. I generally prefer having an
> object that represents the URL and lets me get what I want from it, rather
> than having to pass the bits around to separate parsing functions. The
I agree. This is really convenient when one comes to know about it.
Thanks,
Senthil
--
O.R.Senthil Kumaran
http://uthcode.sarovar.org
More information about the Python-Dev
mailing list