[mod_python] mod_python and importing cheetah templates

Graham Dumpleton grahamd at dscpl.com.au
Thu Dec 15 15:29:14 EST 2005


On 16/12/2005, at 2:45 AM, Ognen Duzlevski wrote:

> Hi all,
>
> I have a directory structure as such:
>
> dir1
>      templates
>
> In dir1/templates I store cheetah templates which are compiled with 
> cheetah-compile into python files.
>
> dir1/main.py is a file that looks at a req.filename and decides to 
> load a python module.
>
> So when a request comes for dir1/templates/something.py - it is 
> imported and its respond() method is called.
>
> So far so good. However, if something.py is trying to use Cheetah's 
> #import <module>, its search path appears to be dir1/ and not 
> dir1/templates where something.py lives. I can see why this might be 
> but how do I go about fixing it?

You need to look at manually specifying the PythonPath directive to
include "dir1" and "dir1/templates", both as absolute paths.

Graham



More information about the Mod_python mailing list