Alberto Valverde wrote: > I had a similar problem when mounting Trac inside a Pylons application > as a controller. Apparently, at some stage environ['wsgi.input'] was > consumed hence POST requests were seen blank by Trac once they reached it. > > I solved it using this piece of middleware [1] stacked closest to the > server [2] to cache input in a regular temporary file so it can be > 'rewound' before passing the request to Trac [3].
WebOb had some functions to do this, but after thinking about it I made it a bit easier. With WebOb trunk you can now do: req = Request(environ) req.make_body_seekable() And then at any time you can do req.body_file.seek(0) (or environ['wsgi.input'].seek(0)) before sending the request on to another application. req.copy() also does this, but if the body has been eaten by something like paste.request.parse_formvars (what all but the tip of Pylons uses, I think) then it won't really work, so you have to prep the environment this way. It's about the same thing as what you did, but you'd be better off using tempfile, and I think just making the body seekable is good enough -- adding a new key isn't really necessary. The whole readable request body is kind of a mess in WSGI, I'm afraid. Specific code to re-serialize a file upload request would still be nice, as it makes it possible to lazily do this, without having to create temporary files at all (since all the necessary information remains around in the parsed req.POST). Note, though, that while that would fix webob-using frameworks, other WSGI stuff might still destructively read the request body, and make_body_seekable will fix even those cases. -- Ian Bicking : [EMAIL PROTECTED] : 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 -~----------~----~----~----~------~----~------~--~---
