[mod_python] Help with apache.import_module

donnie donnie at darthik.com
Wed Aug 18 13:39:50 EDT 2004


I am having problems importing a module when using mod_python.
Here is the error I receive...

--------begin-----------
Mod_python error: "PythonHandler mod_python.publisher"

Traceback (most recent call last):

  File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 299, in HandlerDispatch
    result = object(req)

  File "/usr/lib/python2.3/site-packages/mod_python/publisher.py", line 98, in handler
    path=[path])

  File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 457, in import_module
    module = imp.load_module(mname, f, p, d)

  File "/var/www/python/blah.py", line 2, in ?
    mymodule = apache.import_module('mymodule', log=1)

  File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 454, in import_module
    f, p, d = imp.find_module(parts[i], path)

ImportError: No module named mymodule
----------end---------

This is the file I am executing.
filename: blah.py
--------begin-----------
from mod_python import apache
mymodule = apache.import_module('mymodule', log=1)

def main(req):
  num = 100
  blah = mymodule.mytest(num)
  req.write("this is a test, blah = %s" % blah)
  return
---------end----------

Here is the file that contains the module that I am trying to import.
filename: mymodule.py
--------begin----------
def mytest(num):
  blah = num
  return blah
--------end------------

I am not sure what I am doing wrong....
The files are located in /var/www/python/
and blah.py is loaded like this: http://localhost/python/blah.py

Any help would be greatly appreciated.
I am very new to python and modpython, but I am hooked!

Thank you.

--
Donnie

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://modpython.org/pipermail/mod_python/attachments/20040818/5e53ea1a/attachment.bin


More information about the Mod_python mailing list