[Web-SIG] problem with wsgiref.util.request_uri and decoded uri
Manlio Perillo
manlio_perillo at libero.it
Wed Jul 23 15:45:43 CEST 2008
I'm having a nightmare with encoded/decoded uri and request_uri function:
>>> from wsgiref.util import request_uri
>>> environ = {
... 'HTTP_HOST': 'www.test.org',
... 'SCRIPT_NAME': '',
... 'PATH_INFO': '/b%40x/',
... 'wsgi.url_scheme': 'http'
... }
>>> print request_uri(environ)
http://www.test.org/b%2540x/
Here I'm assuming that the WSGI gateway *does* not decode the uri.
The result of request_uri is incorrect, in this case.
On the other hand, if the WSGI gateway *do* decode the uri, I can no
more handle '/' in uri.
I can usually avoid to have '/' in uri, but right now I'm implementing a
WSGI application that implement a restfull interface to an SQL database:
http://hg.mperillo.ath.cx/wsgix/file/tip/wsgix/contrib/sqltables.py
so I can not avoid fields with '/' character in it.
The proposed solution in a previous thread
http://mail.python.org/pipermail/web-sig/2008-January/003122.html
is to implement a custom encoding scheme (like done in MoinMoin).
There are really no other good solutions?
Assuming that WSGI requires the uri to not be encoded, then the solution
is to do modify the request_uri function replacing:
quote(SCRIPT_NAME) with:
quote(unquote(SCRIPT_NAME))
?
Where can I find informations about alternate encoding scheme?
Thanks Manlio Perillo
More information about the Web-SIG
mailing list