Reputation: 24503
This is a first step for my in Python
on a Linux
web-server using mod-WSGI
.
I'm trying to get all of the cell
parameters from the URL in a list like this:
...&cell=&cell=1&cell=2&cell=3&cell=4&cell=5&cell=6&cell=7&cell=8&...
So I started with code like this:
def application(environment, start_response):
import cgi
form = cgi.FieldStorage(fp = environment['wsgi.input'], environ = environment)
temp_table_inputs=form.getlist('cell')
But I found that the first cell
parameter is missing from the list (I presume because getlist removes it as the content is blank).
Two questions:
getlist
? Note: I know the cell
stuff has a positional dependency but I'd rather look for a way to cope with that before naming the parameters according to their position (I inherited the code and quite a bit depends on the positional stuff, so renaming things will take a lot of effort).
Upvotes: 1
Views: 1656
Reputation: 4600
According to the documentation:
The FieldStorage instance can be indexed like a Python dictionary. It allows membership testing with the in operator, and also supports the standard dictionary method keys() and the built-in function len(). Form fields containing empty strings are ignored and do not appear in the dictionary; to keep such values, provide a true value for the optional keep_blank_values keyword parameter when creating the FieldStorage instance.
Does it solve your problem?
Upvotes: 4