[mod_python] from mod_python import apache

Iker Arizmendi iker at research.att.com
Thu Aug 19 19:44:10 EDT 2004


Hello all,

I have a PSP page, say test.psp, that does an import
of a module called mymod.py. In this module I have
something like the following

     from mod_python import apache

     def test():
         req.write("this is a test")

My test.psp page imports this module and tries
to invoke the test() method, but I get the
following error:

     NameError: global name 'req' is not defined

I've tried various combinations of import statements
in mymod.py with no luck. How can I make the req
object available to the module? I've verified that
the its available to test.psp, but when the PSP page
calls the module - boom.

Here's my Apache config as well:

    Listen 80
    NameVirtualHost *:80
    <VirtualHost *:80>
       <Directory "/home/iker/www/">
          AddHandler mod_python .psp
          PythonHandler mod_python.psp
          PythonDebug On
          PythonPath "['/path/to/mymodule/'] + sys.path"
          Options FollowSymLinks +Indexes
          AllowOverride All
          Order allow,deny
          Allow from all
       </Directory>
       ServerName rose
       ServerAlias localhost
       DocumentRoot /home/iker/www/
       LogLevel debug
    </VirtualHost>


Thanks,
Iker



-- 
Iker Arizmendi
AT&T Labs - Research
Speech and Image Processing Lab
e: iker at research.att.com
w: http://research.att.com



More information about the Mod_python mailing list