[mod_python] [SPAM] URL returned by test.py

Jorey Bump list at joreybump.com
Sat Nov 10 14:14:18 EST 2007

Peter Hollenbeck wrote, at 11/09/2007 09:25 PM:

> I open http://localhost/test.html
> Test.html calls test.py
> Test.py returns an html page with a link to an image in
> /srv/www/htdocs/pics/1998/...
> But the link displayed in the browser is
>     http://localhost/test/test.py/pics/1998/...
> not
>     http://localhost/pics/1998/...
> Can anyone tell me why this is?

You are using a relative path.

> What can I do to get the link without "/test/test.py"

Use an absolute path from the site root.

Change this:

>     link = '<a href="pics/1998/9804/bcsi/98042118.jpg"><img
> src="pics/1998/9804/bcsi/98042118tn.jpg">Logging road</a>'

To this:

     link = '<a href="/pics/1998/9804/bcsi/98042118.jpg"><img 
src="/pics/1998/9804/bcsi/98042118tn.jpg">Logging road</a>'

This problem would occur using any language. It's not specific to 
mod_python. The browser will treat relative paths as relative from the 
currently displayed page.

More information about the Mod_python mailing list