How to parse multi-part content

Dave Kuhlman dkuhlman at rexx.com
Tue Sep 28 01:03:06 CEST 2004


Dave Kuhlman wrote:

> John J. Lee wrote:
> 
>> Dave Kuhlman <dkuhlman at rexx.com> writes:
>> [...]
>>> In case you are curious, this is content posted to my Zope server
>>> when I include an element '<input type="file" .../>' in my form.
>> [...]
>> 
>> *Surely* Zope has a standard way of doing this.  Try a Zope list?
>> 
> 
> That's a good suggestion.  Thanks.  Zope people are Python people,
> so they would give me the kind of help I'd need.  I'll ask on the
> Zope users list.
> 
> However, there is nothing Zope-specific about this.  The content
> was produced by my Web browser (actually two Web browsers that I
> test with: Opera and Firefox).
> 

I was wrong.  You were right.  There is a Zope way to do this.
Thanks for pushing me to dig deeper.  It's a much easier way, too.

If there are any Zopesters reading, here is how to do it:

    def my_external_method(request, ...):
        # Retrieve a stream-like object.
        myStream = request['myFileData']
        # Read the data from the stream object.
        data = myStream.read()

My problem was that I was so sure that I had to retrieve and parse
the content in the body of the request.

Thanks for help.

Dave

-- 
Dave Kuhlman
http://www.rexx.com/~dkuhlman



More information about the Python-list mailing list