Oh, it just occurred to me what's happening.  WebOb is not replacing
the body with an equivalent body; it tries to put back a
lazily-recreated body that matches the original body when it parses
the POST request, but it only works for application/x-www-urlencoded,
not multipart/form-data.  A not very great fix is just accessing
req.body, and it should save the body verbatim when that attribute is
accessed.  Otherwise WebOb needs to recreate the body more correctly.

What's odd is that usually this isn't a problem because WebOb puts the
parsed fields in a special key in environ, and then just uses that
instead of reparsing the body.  I'm not sure why that isn't happening,
or even why the request body is being parsed in this particular case.


On Mon, May 18, 2009 at 1:38 AM, John Smallberries
<[email protected]> wrote:
>
> Ummm, again, this works just fine if I remove that no-op middleware
> from the stack. The controller would then receive a populated POST
> dictionary that includes a FieldStorage element from which it can read
> the file contents. With the middleware in place, it's blank. Is there
> something more the middleware should be doing? Is it my form that is
> the problem? Here's some minimal html for a file upload form that
> fails in the same way as the above:
>
> <html>
> <body>
> <form action="/test" enctype="multipart/form-data" method="post">
> <input name="upload" size="50" id="upload" type="file">
> <input  value="Submit" type="submit">
> </form>
> </body>
> </html>
>
>
>
> On May 15, 2:22 pm, Ian Bicking <[email protected]> wrote:
>> Your request looks weird:
>>
>> On Fri, May 15, 2009 at 2:57 PM, John Smallberries
>>
>> <[email protected]> wrote:
>> > Logfile output from the above:
>>
>> > 2009-05-15 12:45:31 INFO  handling request POST /testform
>> > Accept: text/xml,application/xml,application/xhtml+xml,text/
>> > html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
>> > Accept-Encoding: gzip, deflate
>> > Accept-Language: en-us
>> > Cache-Control: max-age=0
>> > Connection: keep-alive
>> > Content-Length: -1
>> > Content-Type: multipart/form-data; boundary=----
>> > WebKitFormBoundaryGA7kzcYGAhBstwLx
>>
>> So, it expects a form-data style body with the given boundary
>>
>> > Host: localhost:5000
>> > Referer:http://localhost:5000/
>> > User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us)
>> > AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1
>>
>> > upload=FieldStorage%28%27sysdump%27%2C+%27Case_45815_sysdump-Woking-
>> > Bisley-20080702-163019.tgz%27%29&case_number=
>>
>> But the request body is actually application/x-www-form-urlencoded
>>
>> --
>> Ian Bicking  |  http://blog.ianbicking.org
> >
>



-- 
Ian Bicking  |  http://blog.ianbicking.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to