[mod_python] importing from a PSP file

Simon Wittber simonwittber at gmail.com
Thu Jan 6 01:30:41 EST 2005


We've just started using mod-python PSP, so please excuse my ignorance. 

I found that I cannot import modules which exist in the same folder as
the psp file being served by apache.

eg:
The file:

/home/simon/public_html/test.psp

cannot import:

/home/simon/public_html/package/module.py

unless the path '/home/simon/public_html' is sys.path.appended at the
top of the psp page.

To get around this problem, I added the following lines:

cwd = str(os.path.split(self.filename)[0])
sys.path.append(cwd)

under line 207 in '/usr/lib/python2.3/site-packages/mod_python/psp.py'
which cleared up the problem.

Has anyone else come up against this problem? Does another (better)
solution already exist somewhere else in mod-python?

Sw.


More information about the Mod_python mailing list