Phillip J. Eby ha scritto:
At 06:27 PM 5/5/2008 +0200, Manlio Perillo wrote:
Phillip J. Eby ha scritto:
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/'
That's a relative URL that's also an absolute path. Try a relative URL
like './a/b', or just plain '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.
Yes, and you might want to use it as the base against which a relative
URL will be resolved -- i.e. an application-relative URL, vs. a
request-relative URL. In fact, application_uri() would probably be
*more* useful, since if you want a request-relative URL, there's no need
to turn it into an absolute URL, since you could just use it in its
relative form.
Yes, but this is not always the case.
Note, however, that in either case, using a relative URL that's an
absolute path (e.g. '/a/b'), will still produce the same result as your
function would. It's just that urljoin also works properly for all
kinds of relative urls, not just the absolute-path subset.
You are right, thanks.
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