开发者

How do I get an instance of BaseHTTPRequestHandler instantiated during request handling inside an action code?

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.outp开发者_如何学JAVAut': self.wfile

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜