Insane Problem

Victor Subervi victorsubervi at gmail.com
Thu Dec 3 11:52:25 EST 2009


On Thu, Dec 3, 2009 at 12:38 PM, Carsten Haese <carsten.haese at gmail.com>wrote:

> 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.
>

Thank you! Well, I suspected it wasn't a bug either, but I was at my wit's
end and pulling straws.
Thanks again!
V
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091203/71cf0ec4/attachment-0001.html>


More information about the Python-list mailing list