>
> 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.

This looks very useful, I'll probably rewrite the code I posted sometime
to make use of this feature and make it simpler.

> It's about the same thing as what you did, but
> you'd be better off using tempfile,

tempfile has actually been one of my most recent discoveries in the
standard library :) Just wanted to get rid of the annoying os.tempnam
warning so I reinvented the wheel.

Alberto


--~--~---------~--~----~------------~-------~--~----~
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