[mod_python] How to get path from URL

Shawn Harrison harrison at tbc.net
Sun Feb 27 17:47:27 EST 2005


Sorry, Graham, I keep getting caught by "Reply" vs "Reply All".

Graham Dumpleton wrote [02/27/05 3:04 PM]:
> 
> On 28/02/2005, at 3:52 AM, Shawn Harrison wrote:
>> This makes no provision for the case where uri = req.hostname.
> 
> Don't understand your last comment, but I don't believe what you have will
> always work. 

Right. The point of the comment was to say that I made no effort to
provide a general solution, only to suggest a direction for exploration.
  Not a very good one at that.

> What you want is:
> 
>   p = 'http://' + req.hostname + req.uri[:-len(req.path_info)]
> 
> Which yields:
> 
>   http://localhost/~grahamd/hclass/page

Well, that's a lot less work, isn't it.

> This will not work though if not the standard server port or if "https" is
> used.

Thanks, I forgot to mention that.

Is the port available in mod_python? I wasn't able to find it when
working with this problem earlier. How about the protocol (https vs http)?

Shawn



More information about the Mod_python mailing list