On Thu, 2010-09-16 at 05:29 +0200, Roberto De Ioris wrote: > About the *.file_wrapper removal, i suggest > a PSGI-like approach where 'body' can contains a File Object. > > def file_app(environ): > fd = open('/tmp/pippo.txt', 'r') > status = b'200 OK' > headers = [(b'Content-type', b'text/plain')] > body = fd > return body, status, headers
I don't see why this couldn't work as long as middleware didn't convert the body into something not-file-like. But it is really an implementation detail of the origin server (it might specialize when the body is a file), and doesn't really need to be in the spec. > or > > def file_app(environ): > fd = open('/tmp/pippo.txt', 'r') > status = b'200 OK' > headers = [(b'Content-type', b'text/plain')] > body = [b'Header', fd, b'Footer'] > return body, status, headers This won't work, as the body is required to return an iterable which returns bytes, and cannot be an iterable which returns either bytes or other iterables (it must be a "flat" sequence). - C _______________________________________________ Web-SIG mailing list Web-SIG@python.org Web SIG: http://www.python.org/sigs/web-sig Unsubscribe: http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com