Insane Problem

Carsten Haese carsten.haese at gmail.com
Thu Dec 3 11:38:36 EST 2009


Victor Subervi wrote:
>     No, it doesn't, because you've only provided one third of what I asked
>     for. I also asked for the code and the inputs that go into it.
> 
> 
> I provided those earlier.

No, you didn't provide the exact code you're running. You provided a
selected snippet you deemed important, but because you don't actually
know what the problem is and where it is, your determination of what's
important is not helpful. You actually managed to snip away the part
that causes the problem.

The code snipped you posted earlier showed cgi.FieldStorage being called
once. The code you're posting now makes it clear that cgi.FieldStorage
is actually called multiple times in a loop:

> [snip...]
> def optionsPrintout(table):
>   form = cgi.FieldStorage()
>   fn = getattr(options, table)
>   ourOptionsNames = []
>   optionsNames, doNotUse  = fn('names')
> 
> [snip...]
>
>   for table in storesTables:
>       [snip...]
>       print optionsPrintout(table)
>       [snip ...]

The problem is that the first call to cgi.FieldStorage() consumes all
POST variables that were given to the script, so any subsequent call
reads an empty file and results in an empty FieldStorage object. Rewrite
your code to construct the FieldStorage object once and refer to that
one object in every pass of the loop.

As you can see, and as I suspected, it's not a bug in the cgi module.

--
Carsten Haese
http://informixdb.sourceforge.net




More information about the Python-list mailing list