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

make GridOut objects in GridFS (more) file-like

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0
    • Component/s: None
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible

      Description

      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.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: