You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-dev@quetz.apache.org by David Fraser <da...@sjsoft.com> on 2004/03/10 09:00:34 UTC
Files in FieldStorage under mod_python 3.1.3
Hi
Submitting a file through a form (multipart/form-data) that has worked
under mod_python 3.0.3 (ended up as a File object) seems to produce a
StringField under mod_python 3.1.3
It seems this part of the diff is responsible (util.py):
@@ -260,10 +224,10 @@
found = []
for item in self.list:
if item.name == key:
- if isinstance(item.file, StringIO.StringIO):
- found.append(StringField(item.value))
- else:
+ if isinstance(item.file, FileType):
found.append(item)
+ else:
+ found.append(StringField(item.value))
if not found:
raise KeyError, key
if len(found) == 1:
Since in mod_python 3.1.3 the file is created using tempfile, item.file
can end up being a tempfile._TemporaryFileWrapper. This does in fact
happen (at least under Windows), resulting in the attachment coming out
as a StringField.
This patch fixes the problem by checking if the file has a "file"
attribute itself, and checking the type of that.
There may be a cleaner way to do it.
David