[mod_python] Distinguishing uploaded files from POST form data

Bart scarfboy at gmail.com
Sun Dec 9 08:45:35 EST 2007

As I recall, files are just one type thing you can store in POST data.
The distinction is made in parsing, so yes, pretty much anything
makes that distinction.
PHP apparently chooses to put them in separate variables, while
(mod_)python doesn't, and you have to test what each member is
an instantiation of, mod_python.util.Field (a file) or StringField (a string).

You can likely imitate that for tests.
...though I get the impression I'm not answering the question you actually had.


On Dec 9, 2007 7:42 AM, Michael M <tactics40 at gmail.com> wrote:
> Hello,
> I'm using mod_python for a project of mine. It's working very nicely, save a
> few quirks.
> My question is how do you distinguish between regular form POST data and
> uploaded files? In other words, I want to be able to take a FieldStorage
> object and split it into something analogous to PHP's $_POST and $_FILES.
> FieldStorage is a sloppy class which is tied way to closely to the
> underlying implementation of HTTP. I was to abstract it so I can more easily
> unittest my system (because mod_python absolutely hates being imported
> outside of Apache). However, as far as I have been able to figure out,
> there's no clear way to tell which is which. I can also imagine that maybe
> PHP does a little black magic and the actual difference between uploaded
> files and post data is fuzzier than Zend would have us all believe. If such
> is the case, what would my best strategy be to try and make a good guess as
> to when data is constitutes an uploaded file?
> Any help would be spectacular.

More information about the Mod_python mailing list