Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-209

make GridOut objects in GridFS (more) file-like

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      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.

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            xemacs Guy K. Kloss
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: