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

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor - P4
    • Resolution: Fixed
    • None
    • 3.0
    • None
    • 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

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

              Dates

                Created:
                Updated:
                Resolved: