[mod_python] importing woes

Todd Boland itodd at itodd.org
Mon Sep 20 14:40:09 EDT 2004


The reason for my woes was obvious.

httpd didn't have correct permissions to read /rpm/lib/RPM while user 
itodd did. This explains why i could import from the command line and 
not in mod_python.

Todd

On Sep 19, 2004, at 9:50 PM, Todd Boland wrote:

> Please allow myself to introduce ... myself. I'm Todd and I'm in love 
> with python. I'm a newbie so please excuse me if the answer to my woes 
> is obvious.
>
> I'm setting up an environment for my first mod_python project. It's a 
> radio-pharmacy manager (not redhat package manager) which lives at 
> /rpm on my file system. The following code raises the exception: 
> "ImportError: No module named RPM."
>
> in httpd.conf, i have:
> PythonPath "sys.path+['/rpm/lib']"
>
> the code:
> from mod_python import apache, psp
> from RPM import database
>
> def index(req, result='success'):
>         template = psp.PSP(req, filename='test.html')
>         template.run({'result':result})
>
> Why can I do the following on the command line without an exception 
> being raised?
>
> itodd at powerbook ~] python
> Python 2.3.4 (#1, Sep 17 2004, 11:09:35)
> [GCC 3.1 20021003 (prerelease)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import sys
> >>> sys.path.append('/rpm/lib')
> >>> from RPM import database
> >>> database
> <module 'RPM.database' from '/rpm/lib/RPM/database.pyc'>
> >>>
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
>



More information about the Mod_python mailing list