[Web-SIG] [proposal] wsgiref.util.abs_url

Manlio Perillo manlio_perillo at libero.it
Mon May 5 18:27:33 CEST 2008


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


More information about the Web-SIG mailing list