Uploaded image for project: 'Motor'
  1. Motor
  2. MOTOR-439

AgnosticGridFSBucket parameters do not match PyMongo's GridFSBucket

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.1
    • Affects Version/s: None
    • Component/s: None
    • None

      Motor's AgnosticGridFSBucket class claims to match PyMongo's GridFSBucket class but the init signatures are not the same. Here's AgnosticGridFSBucket:

      class AgnosticGridFSBucket(object):
          __motor_class_name__ = 'MotorGridFSBucket'
          __delegate_class__ = gridfs.GridFSBucket
      
          def __init__(self, database, collection="fs", disable_md5=False):
      

      And here's PyMongo's GridFSBucket:

      class GridFSBucket(object):
          def __init__(self, db, bucket_name="fs",
                       chunk_size_bytes=DEFAULT_CHUNK_SIZE, write_concern=None,
                       read_preference=None, disable_md5=False):
      

      AgnosticGridFSBucket's init actually implements PyMongo's legacy GridFS class:

      class GridFS(object):
          """An instance of GridFS on top of a single Database.
          """
          def __init__(self, database, collection="fs", disable_md5=False):
      

      I think we can fix this in a backwards compatible way by changing AgnosticGridFSBucket to:

          def __init__(self, db, bucket_name="fs", disable_md5=False
                       chunk_size_bytes=DEFAULT_CHUNK_SIZE, write_concern=None,
                       read_preference=None, collection=None):
              # Preserve backwards compatibility of "collection" parameter
              if collection is not None:
                  warnings.warn('the "collection" parameter is deprecated, use'
                                '"bucket_name" instead', DeprecationWarning)
                  bucket_name = collection
      

            Assignee:
            shane.harvey@mongodb.com Shane Harvey
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: