Function analogous to serve_file for open file objects
I asked the following question:
In cherrypy.lib.static.py there is a method: serve_file(path, content_type=None, disposition=None, name=None) where the argument "path" must be a real file (absolute path). Is there something similar to serve any Python file object?
and got the following answer from Alex Martelli:
From studying http://www.cherrypy.org/browser/trunk/cherrypy/lib/static.py I'd have to say, no: the serve_file function is "monolithic", and does its own bodyfile = open(path, 'rb'), nor does there seem to be any alternative way. Pity, as it would be easy to refactor the function and add another e.g. serve_open_file to cover your case, having both delegate to an internal function for the "hard" logic such as multipart/byteranges serving. May be worth your while to open a feature request ("enhancement ticket") on cherrypy.org -- may not be a killer feature but I can see use cases, and implementing it wouldn't be hard for the cherrypy people (visit their site and follow the instructions on the page to "log in" to it).
It would be really nice to have this function!
Reported by email@example.com