Mod_python error: AttributeError: 'str' object has no attribute 'status_code'

1,253 views
Skip to first unread message

Nihaar Gupta

unread,
Apr 5, 2010, 3:49:26 PM4/5/10
to Django users
Help. I'm a bit of an apache/mod_python noob and am not sure what is
causing this error. I get this at page load every so often (not all
the time). Sometimes the page loads fine and sometimes it throws this
exception.

Guessing from the fact that this occurs only sometimes, perhaps this
is a load/scaling issue with mod_python? It's happening in my
production system where I do get a lot of hits.

Any input/advice would be much appreciated.

Cheers,
Nihaar

MOD_PYTHON ERROR

Traceback (most recent call last):

File "/usr/lib64/python2.6/site-packages/mod_python/importer.py",
line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)

File "/usr/lib64/python2.6/site-packages/mod_python/importer.py",
line 1229, in _process_target
result = _execute_target(config, req, object, arg)

File "/usr/lib64/python2.6/site-packages/mod_python/importer.py",
line 1128, in _execute_target
result = object(arg)

File "/usr/lib/python2.6/site-packages/django/core/handlers/
modpython.py", line 228, in handler
return ModPythonHandler()(req)

File "/usr/lib/python2.6/site-packages/django/core/handlers/
modpython.py", line 205, in __call__
response = middleware_method(request, response)

File "/usr/lib/python2.6/site-packages/django/middleware/common.py",
line 83, in process_response
if response.status_code == 404:

AttributeError: 'str' object has no attribute 'status_code'


bruno desthuilliers

unread,
Apr 6, 2010, 3:47:54 AM4/6/10
to Django users

Obviously a string is returned instead of a response object. Does it
always happen on the same view, or is it a random error ?

Anyway : the best way to trace the problem would be to add a couple
lines of code around line 83 to catch the exception and log the
offending string *and* the whole traceback.

My 2 cents...

Reply all
Reply to author
Forward
0 new messages