Reputation: 1388
My python has become quite rusty as I haven't used it for quite a while and am stuck with an issue I am not able to figure out.
The python program should accept a form's data sent by a web page, and return some JSON response codes back to it. Everything works fine except when the data is sent:
def application(environ, start_response):
""" Process the form data, spit out the reponse """
# code here extracts the form
# data and the response code is
# stored in info
# everything done, output now
output(environ, start_response, info)
def output(environ, start_response, info):
# debug
print >> environ['wsgi.errors'], "BACK TO THE BROWSER"
feedback = json.dumps(info)
# debug
print >> environ['wsgi.errors'], feedback
status = "200 OK"
headers = [('Content-Type', 'application/json; charset=UTF-8'), ('Content-Length', str(len(feedback)))]
start_response(status, headers)
return [feedback]
The error log says:
...
[wsgi:error] ... BACK TO THE BROWSER[wsgi:error] ... {"errors": [1430360477881, 1430233459050]}
[wsgi:error] ... mod_wsgi (pid=1654): Exception occurred processing WSGI script '/tmp/mod_wsgi-localhost:8000:0/htdocs/'.
[wsgi:error] ... TypeError: 'NoneType' object is not iterable
...
Ok, Python is complaining that something it expects to be iterable is None. But which iterable is Python complaining about in this function? (Note that I am using mod_wsgi directly without any frameworks / modules).
Upvotes: 2
Views: 10856
Reputation: 16790
You need to return the response:
return output(environ, start_response, info)
Upvotes: 3