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

Allow PyMongo to work with any object that implements mapping protocol, not just dicts

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.0
    • Affects Version/s: None
    • Component/s: None
    • Minor Change

      The current implementation of the BSON C extension and the python code requires that all documents and specs be dict types or inherit from dict.

      In order to be more "Pythonic", they should allow any object which implements the mapping protocol (dict-like objects) to be used.

      In order to do this, the C extension would need to use PyMapping_Check instead of PyDict_Check, and PyObject_GetItem instead of PyDict_GetItem. The python code would need to use operator.isMappingType instead of isinstance(doc_or_spec, dict) for Python <2.6 and isinstance(doc_or_spec, collections.Mapping) for Python >=2.6.

            Assignee:
            luke.lovett Luke Lovett
            Reporter:
            jake@about.me Jake
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: