views:

29

answers:

1

I need to access the rfile and wfile properties of a request handler instance. AFAIK, such a handler is instantiated by the framework during request lifetime.

Update: I found that rfile is accessible through request.environ['wsgi.input']. To access wfile I've do a hack with the additional line in Paste sources, httpserver.py:210:

,'wsgi.output': self.wfile

But I wonder if there is a better solution...

+1  A: 

Better do like this http://pythonpaste.org/webob/reference.html#body-app-iter

In pylons action:

 f = response.body_file
 f.write('hey')

The response.body_file is only like a file object, but not real stream. For more details read http://www.python.org/dev/peps/pep-0333/#id22

estin
The problem is that I need to provide this file-like object to the third-party code providing that all written to f data will be immediately transmitted over a connection.
eigenein
By wsgi standart you must transmit you data by blocks without delay in transimiting. You can write some itarator for yielding this blocks out .
estin