Un(der)documented bits of cgi.py

B

Bob Kline

I'm trying to detect and intelligently deal with problems created when a
user of a Python CGI page uploads a file and then gets impatient and
clicks on some other button or the browser's cancel button (or even
closes the page). If the file is large enough, and the user is
impatient enough, this can result in the FieldStorage.file object
getting some, but not all of the bytes from the user's file, with no
documented means of detecting that this has happened. Poking around in
the code for cgi.py in the standard library, it appears that there is an
undocumented 'done' attribute which might be useful here (it seems as if
it might get set to -1 when this condition is encountered), but of
course one is reluctant to leave behind software which relies on
undocumented behavior of packages, since those bits have a way of
disappearing in the middle of the night, suddenly breaking one's
software. Can anyone think of a good reason why it would not be
desirable to expose a publicly documented means of detecting the
condition described above?

Cheers and thanks!
Bob Kline
 
A

Aahz

I'm trying to detect and intelligently deal with problems created when
a user of a Python CGI page uploads a file and then gets impatient
and clicks on some other button or the browser's cancel button (or
even closes the page). If the file is large enough, and the user is
impatient enough, this can result in the FieldStorage.file object
getting some, but not all of the bytes from the user's file, with no
documented means of detecting that this has happened. Poking around
in the code for cgi.py in the standard library, it appears that there
is an undocumented 'done' attribute which might be useful here (it
seems as if it might get set to -1 when this condition is encountered),
but of course one is reluctant to leave behind software which relies
on undocumented behavior of packages, since those bits have a way
of disappearing in the middle of the night, suddenly breaking one's
software. Can anyone think of a good reason why it would not be
desirable to expose a publicly documented means of detecting the
condition described above?

What I suggest doing is submitting a doc patch to
http://bugs.python.org/
explaining the ``done`` attribute with a note that you're not sure
whether the attribute is intended to be undocumented. Alternatively, you
might look in the svn logs to find out who added the ``done`` attribute
and if they're still active in the Python community, ask them directly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top