This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author phep
Recipients eric.araujo, orsenthil, phep
Date 2011-07-26.20:56:47
SpamBayes Score 5.79925e-13
Marked as misclassified No
Message-id <1311713808.12.0.227146380273.issue9968@psf.upfronthosting.co.za>
In-reply-to
Content
Hi,

This was test code :-/. It was not under revision control and 
unfortunately, as I feared then, it turned out I had to stop
working shortly after my last message on the low-priority
project that made me report this issue .

Yet, I have a tarball of a presumably-not-so-different version
of the code and I experimented with it this afternoon. Actually,
I could not reproduce the problem I reported in msg117933. So, 
basically, the idea of replacing tempfile.TemporaryFile() by
tempfile.NamedTemporaryFile() seems to really be valid, whatever
the position of the form field.

Yet I found another problem, quite reproducible that one, that
seems to have some fame on Google. Due to the way cgi.__write()
is written, contents of uploaded files with small sizes will be
stored as StringIO. Consequently, sort-of calling
fieldstorage['filenamefield'].file.name will fail. De facto,
this may actually be the error I alluded to in msg117933 - I 
honestly cannot remember what I observed then: « c'est
l'âge...».

So the patch should then be one line longer: we would need
to change __write() to add a check on the value of 'filename' :
-           if self.__file.tell() + len(line) > 1000:
+           if self.filename or self.__file.tell() + len(line) > 1000:

This way, long textareas (for example), keep being stored on
disk if this has any importance.

There is yet one question I cannot answer: where does the 1ko 
barrier come from? Was it only chosen out of performance
considerations, or was there another reason? As I am quite new 
to Python I fear I may miss something obvious.

HTH
History
Date User Action Args
2011-07-26 20:56:48phepsetrecipients: + phep, orsenthil, eric.araujo
2011-07-26 20:56:48phepsetmessageid: <1311713808.12.0.227146380273.issue9968@psf.upfronthosting.co.za>
2011-07-26 20:56:47pheplinkissue9968 messages
2011-07-26 20:56:47phepcreate