-
Type: Improvement
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Fully Compatible
GridFS is an implementation of a file system in the DB. So one is likely to do similar things to the files as with a conventional file system. Unfortunately the GridOut objects returned by pymongo when accessing a file are missing some crucial file-like object features. If an object is properly file-like, many operations can be handled in a much more efficient way, without having to do them in custom code "yourself". These things could be for example serving the file out in a WSGI web application using the wsgi.file_wrapper, using the handle with a context manager (the "with" statement), passing the object around to other modules/functions to do operations straight away like opening an image, ...
Methods that I've so far stumbled over which seem to be missing particularly are these:
- close()
- fileno()
This offers a more comprehensive overview in the Python documentation on flie and file-like objects:
http://docs.python.org/library/stdtypes.html#file-objects
A change for this would not break anything backwards, as only additional methods would be offered.
- is related to
-
PYTHON-2824 Make GridOut implement full io.IOBase spec
- Closed