Nicolas Lehuen
nicolas at lehuen.com
Tue Jun 6 01:55:01 EDT 2006
Hi David, There was a thread a while ago on the development mailing list : http://mail-archives.apache.org/mod_mbox/httpd-python-dev/200511.mbox/%[email protected]%3e It turns out that there is no other way than doing this yourself in 3.2.x and before. Graham has added a construct_url method to the request object which exposes the ap_construct_url function from the Apache API and does precisely what you want. Unfortunately it'll be only present in mod_python 3.3, unless it is backported to the 3.2 branch. Regards, Nicolas 2006/6/6, David Bear <David.Bear at asu.edu>: > I've been looking at ways to get a full url into my script and all the > methods I see on the req object seem lacking in making this simple. > > in the example on the web site there is a publisher script that has > this: > > > def _base_url(req, ssl=0): > ''' > see psp_site example for this function ''' > host = req.headers_in.get('host', req.server.server_hostname) > if not ':' in host: > port = req.connection.local_addr[1] > if port != 80 and not ssl: > host = "%s:%d" % (host, req.connection.local_addr[1]) > if ssl: > base = 'https://' + host + req.uri > else: > base = 'http://' + host + req.uri > return os.path.split(base)[0] > > this seems really clunky -- and it is using some attributes on the req > object that don't seem to be documented on the web site. I suppose the > easy way to test where a request was made over ssl/tls is ?? seems it > set in the funtion call. Is req.connection.local_addr[1] the port > number? I can't seem to find this documented on the modpython site. > > > > -- > David Bear > phone: 480-965-8257 > fax: 480-965-9189 > College of Public Programs/ASU > Wilson Hall 232 > Tempe, AZ 85287-0803 > "Beware the IP portfolio, everyone will be suspect of trespassing" > _______________________________________________ > Mod_python mailing list > Mod_python at modpython.org > http://mailman.modpython.org/mailman/listinfo/mod_python >
|