[mod_python] addhandler or sethandler

David Bear David.Bear at asu.edu
Tue May 16 21:12:38 EDT 2006

I'm trying to better understand the directive semantics. So, I created
2 .htaccess files.

the mpt.py file is the same. However I get different results between
each .htaccess file.

SetHandler mod_python
PythonHandler mod_python.publisher
PythonDebug On

The above file produces an error when viewing mpt.py:

Mod_python error: "PythonHandler mod_python.publisher"

Traceback (most recent call last):

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

  File "/usr/lib64/python2.4/site-packages/mod_python/publisher.py",
line 98, in handler

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

  File "/work/servers/www/htdocs/apep/index.py", line 22

    return "Falling through to main "

SyntaxError: 'return' outside function

However, the below htaccess file produces the expected result, it
executes the python function, which is:

from mod_python import apache

def handler ( req ):
  req.content_type = "text/plain"
  req.write( "mod python test \n hello world" )
  return apache.OK

 AddHandler python-program .py
 PythonHandler mpt
 PythonDebug On

I hate to bug this group but can someone explain the difference?

David Bear
phone: 	480-965-8257
fax: 	480-965-9189
College of Public Programs/ASU
Wilson Hall 232
Tempe, AZ 85287-0803
 "Beware the IP portfolio, everyone will be suspect of trespassing"

More information about the Mod_python mailing list