Il giorno 16/set/2010, alle ore 08.37, Masklinn ha scritto: >> I generally like it. >> >> 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 >> > As far as I understand it, `body` is an iterable so there should not be any > problem with sending a file through directly in this manner. Better, the web3 > spec specifically mandates that if the `body` iterable has a `close` method > it must be called on request completion (second-to-last paragraph in the > specification details section [0]). So a File Object as a body is already > completely handled by web3. > > On the other hand, `body` has to yield bytes, so `fd = open('/tmp/pippo.txt', > 'rb')` I think. >
In this case i do not see a need for wsgi.file_wrapper replacement. The Web3 gateway/hosting system can manage File-Like Object the way it wants (and transparently for the application) -- Roberto De Ioris http://unbit.it JID: robe...@jabber.unbit.it _______________________________________________ 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