[mod_python] NameError: name 'req' is not defined

Handrix handrix at gmail.com
Mon Oct 13 06:37:46 EDT 2008


Hello,

When i try to execute a python script in modpython i got this error:
NameError: name 'req' is not defined
that is the content of my script

from mod_python import apache

def handler(req):
    req.content_type = 'text/plain'
    req.write("Hello World!")
    return apache.OK

handler(req)
here is my apache config

<Directory "/var/www/python">
AddHandler python-program .py
PythonHandler  mod_python.publisher
PythonDebug On
</Directory>

And here the traceback

Mod_python error: "PythonHandler mod_python.publisher"

Traceback (most recent call last):

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

  File "/usr/lib/python2.4/site-packages/mod_python/publisher.py",
line 204, in handler
    module = page_cache[req]

  File "/usr/lib/python2.4/site-packages/mod_python/cache.py", line
82, in __getitem__
    return self._checkitem(name)[2]

  File "/usr/lib/python2.4/site-packages/mod_python/cache.py", line
124, in _checkitem
    value = self.build(key, name, opened, entry)

  File "/usr/lib/python2.4/site-packages/mod_python/publisher.py",
line 77, in build
    return ModuleCache.build(self, key, req, opened, entry)

  File "/usr/lib/python2.4/site-packages/mod_python/cache.py", line
371, in build
    exec opened in module.__dict__

  File "/var/www/python/index.py", line 8, in ?
    handler(req)


Please can any one help.
Best regards,


-- 
Handrix
Network Engineering/Security
http://securynix.co.cc/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20081013/8514b1bb/attachment.html


More information about the Mod_python mailing list