Jef Dodson
jefdodson at yahoo.com
Sun Feb 13 03:31:19 EST 2005
OK, another question for all of you mod_python experts. I would like to use a template engine (cheetah) with mod_python. I have a directory structure as follows: /scripts /images /templates I am using mod_python.publisher and have a script in the /scripts directory named my_script with a function named test so the function will process the request from the url: http://www.mysite.com/scripts/my_script/test I am able to get the path to the template file by doing the following: cwd = os.path.dirname(__file__) filepath = os.path.join(cwd, '../templates/test.tmpl') So, that all works fine. The problem is, in the test.tmpl file, I have a static reference to an image file that lives in /images so the html looks like this: <img src="../images/my_image.gif"> This doesn't work. However, if I change the link the following, it works: <img src="../../images/my_image.gif"> I guess the browser uses /scripts/my_script/ as the base of the url, so a reference to ../images in the template file would resolve to /scripts/images which doesn't exist. So, my question is this: how do I deal with the general problem of relative paths without resorting to changing all the links in my templates or putting a <base> tag in all the templates? Keep in mind that these are static paths, so changing them programmatically is not an option in this case. There must be some really clean and elegant way to solve this problem using the almighty httpd.conf file, right?! Thanks! Jef __________________________________ Do you Yahoo!? The all-new My Yahoo! - What will yours do? http://my.yahoo.com
|