I found the solution to my (dumb) problem and listed it below.
I'm using Python 2.7.1+ on Ubuntu 11.04. The client/server are on the same computer.
From the Wing debugger, I know the server code is being called and I can walk through the code one line at a time. In this instance, I know 22 bytes were transferred.
In Firebug, I saw this data under the Net Post tab:
Parameter application/x-www-form-urlencoded
fname first
lname last
Source
Content-Type: application/x-www-form-urlencoded
Content-Length: 22 fname=first&lname=last
This is the client code that I'm using:
<html>
<form action="addGraphNotes.wsgi" method="post">
First name: <input type="text" name="fname" /><br />
Last name: <input type="text" name="lname" /><br />
<input type="submit" value="Submit" />
</form>
</html>
And this is the server code:
import urlparse
def application(environ, start_response):
output = []
# the environment variable CONTENT_LENGTH may be empty or missing
try:
# NOTE: THIS WORKS. I get a value > 0 and the size appears correct (22 bytes in this case)
request_body_size = int(environ.get('CONTENT_LENGTH', 0))
except (ValueError):
request_body_size = 0
try:
# environ['QUERY_STRING'] returns ""
**values = urlparse.parse_qs( environ['QUERY_STRING'] )**
except:
output = ["parse error"]
In the Wing debugger, I've verified that data is being passed from the client to the server:
>>> environ['wsgi.input'].read()
'fname=first&lname=last'
FOUND MY PROBLEM. I COPIED AND PASTED IN THE WRONG CODE. THIS IS THE CODE I WAS USING FOR FORMS BUT STOP ADDING IT WHEN I STARTED USING AJAX AND STOPPED USING FORMS. Now, everything is working fine.
# When the method is POST the query string will be sent
# in the HTTP request body which is passed by the WSGI server
# in the file like wsgi.input environment variable.
request_body = environ['wsgi.input'].read(request_body_size)
values = parse_qs(request_body)