cherrypy / cherrypy

CherryPy is a pythonic, object-oriented HTTP framework. https://cherrypy.dev
https://docs.cherrypy.dev
BSD 3-Clause "New" or "Revised" License
1.8k stars 357 forks source link

mod_python 'NoneType' object is not subscriptable #1051

Closed ghost closed 8 years ago

ghost commented 13 years ago

Originally reported by: Anonymous


Wanting to run a cherrpy application using apache2+mod_python I tried the sample at DeployTemplate, but even using that code it does not work, all I get is this exception in 'site.log':

[02/Mar/2011:14:06:37] MOD_PYTHON Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cherrypy/_cpmodpy.py", line 229, in handler
    response.body, response.stream)
  File "/usr/lib/python2.7/site-packages/cherrypy/_cpmodpy.py", line 247, in send_response
    req.status = int(status[:3])
TypeError: 'NoneType' object is not subscriptable

my .htaccess is as following:

SetHandler python-program

PythonPath "sys.path+['/path/to/code']"
PythonHandler cherrypy._cpmodpy::handler
PythonOption cherrypy.setup myapp::serverless
PythonDebug On

To further find more details, I've added some print statements to _cpmodpy.py and here is the arguments for send_response:

req: <mp_request object at 0xbe676ac>
status: None
headers: [('Date', 'Wed, 02 Mar 2011 13:20:58 GMT'), ('Content-Length', '12'), ('Content-Type', 'text/html;charset=ISO-8859-1'), ('Server', 'CherryPy/3.2.0')]
body: ['Hello World!']
stream: False

It all looks fine, except that 'status' is not set.

I am running the following versions:

Reported by ext-cherrypy.org@sidvind.com


ghost commented 12 years ago

Original comment by Robert Brewer (Bitbucket: fumanchu, GitHub: fumanchu):


Same problem as #1055. Moved mod_python to read response.output_status in [2817].