Phillip J. Eby ha scritto:
At 11:03 PM 5/2/2008 +0200, Manlio Perillo wrote:
Hi.
I think that a function like (not tested):
def abs_url(environ, relative_url):
"""Return the absolute url"""
[...]
url += quote(relative_url)
return url
would be an useful addition to the wsgiref.util module.
What do you think?
I think that it doesn't accept a relative URL, it accepts an absolute path.
What do you mean?
environ = {}
setup_testing_defaults(environ)
url = '/a/b/'
self.failUnlessEqual(
util.abs_url(environ, url), 'http://127.0.0.1/a/b/')
I also think that using urlparse.urljoin() with either request_uri() or
application_uri() would be a clearer (and tested) way to obtain an
absolute URL, and more generally useful.
But application_uri also includes SCRIPT_NAME.
Regards Manlio Perillo
_______________________________________________
Web-SIG mailing list
Web-SIG@python.org
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe:
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com