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

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.0
    • Component/s: None
    • Labels:
    • Backwards Compatibility:
      Minor Change

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: