How to parse multi-part content

Tim Roberts timr at probo.com
Sun Sep 26 02:23:23 EDT 2004


Dave Kuhlman <dkuhlman at rexx.com> wrote:
>
>Suppose that I have content that looks like what I've included at
>the end of this message.  Is there something in the standard
>Python library that will help me parse it, break into the parts
>separated by the boundary strings, extract headers from each
>sub-part, etc?
>...
>In case you are curious, this is content posted to my Zope server
>when I include an element '<input type="file" .../>' in my form.

Actually, you get this because your <form> header has
enctype="multipart/form-data".  It happens that file upload only works with
that enctype, but you can use it without a file upload.

That's why cgi.py knows how to parse this.  Look at cgi.parse_multipart.
-- 
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list