[mod_python] Apache1.3.33 + Python2.3.4 + mod_python - Can't get Python templates to work

Brandon Masterson bmasters at direcway.com
Wed Jan 26 03:09:16 EST 2005


Gave it a try but had no luck.  Adding something like this:

filepath = "%s/basic.html" % os.path.dirname(__file__)
templateFile = open (filepath, 'r')

...generated the same error I get if I hard coded the entire absolute path 
in with the template name (e.g. /var/www/pythontest/basic.html).  When I 
make this change, I get the following:

ERROR MESSAGE:
404 Not Found
The requested URL /pythontest/c.py was not found on this server.


At 05:12 PM 1/25/2005 +0100, Nicolas Lehuen wrote:
>I think the problem is the CWD, which is automatically set to / IIRC.
>You have to give an absolute path to your template files. The best way
>to do this is to use the __file__ variable, which gives you the
>absolute path of the current .py file, and navigate from this file
>using the os and os.path modules.





More information about the Mod_python mailing list