File upload should assign cgi.FieldStorage to form.File field's value attribute
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
web.py |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
File uploads seem to cause a little bit of confusion when it comes to retrieving the contents of the file, and the filename. I've attempted to address this issue as outlined here:
The attached patch makes this possible.
The patch modifies web.utils.storify to special-case the ``cgi.FileStorage`` and use its value without modification. It also modifies the form.File by overriding its set_value method. ``value`` propery of the file.File instance contains the entire ``cgi.FileStorage`` instance, file.File's ``filename`` attribute contains the filename, and ``file`` attribute contains the contents of the file.
The most important change that this patch introduces is that there is no longer any need to pass defaults to web.input() before performing form validation.
That will break backward- compatibility.