|
David Bear
David.Bear at asu.edu
Mon Jun 5 20:11:56 EDT 2006
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"
|