I think I figured it out.  I was using web.data() in my handler, which
reads env['wsgi.input'] and caches it.  Later (in an unloadhook) I was
trying to read() env['wsgi.input'], at which point it had already been
read, so it did not return any data.

I was able to use the following workaround though:
    web.ctx.env['wsgi.input'] = StringIO.StringIO(web.data())

Thanks!


On Jul 13, 2:27 pm, andrei <[email protected]> wrote:
> I implemented drag'n'drop into browser window upload and also had to
> retrieve the whole request body
> I think this bit of code should be used before web.input (i use
> web.input after to parse GET parameters)
>
> tmpfile = os.tmpfile()
>         contentLength = int(web.ctx.env['CONTENT_LENGTH'])
>         if contentLength <= 0:
>             raise AssertionError('invalid content length')
>         wsgiInput = web.ctx.env['wsgi.input']
>         while contentLength > 0:
>             chunk = 1024
>             if contentLength < chunk:
>                 chunk = contentLength
>             contentLength -= chunk
>             tmpfile.write(wsgiInput.read(chunk))
>         tmpfile.seek(0)
> web.ctx.env['wsgi.input'] = StringIO()
>
> On Jul 13, 7:30 pm, Mynnx <[email protected]> wrote:
>
>
>
> > I am trying to instantiate a Paste WebOb Request object, which needs a
> > WSGI environ variable.  I noticed that once I do so, there is nothing
> > in the request's 'body' field, even when I'm certain the request
> > POSTed data.
>
> > I would assume that it uses the environ variable 'wsgi.input' to get
> > the body - according to PEP333 it is "an input stream (file-like
> > object) from which the HTTP request body can be read."  I've tried
> > calling .read() on web.ctx.env['wsgi.input'], but nothing is read.
> > Does webpy populate it correctly?

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" 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/webpy?hl=en.

Reply via email to