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

Error behavior in SONManipulator

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.8, 3.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      all

      There is bug with SONManipulator optimization here: https://github.com/mongodb/mongo-python-driver/blob/master/pymongo/database.py#L95

      Due to this bug:

      • we cannot create manipulator that isn't inherited from SONManipulator class. That's not so good.
      • we cannot create two (or more) level manipulators inheritance hierarhy. For example this wouldn't work correct:
        from pymongo.son_manipulator import SONManipulator
        
        
        class ParentManipulator(SONManipulator):
            def transform_incoming(self, son, collection):
                son['collection_name'] = collection.name
                return son
        
            def transform_outgoing(self, son, collection):
                if 'collection_name' in son:
                    del son['collection_name']
                return son
        
        
        class ChildManipulator(ParentManipulator):
            """ 
            It should work like ParentManipulator, but it wouldn't work at call :(
            """
            pass
        
        

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            Last G Last G [X]
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: