(self, son, collection)
return transform_dict(SON(son))
Replace embedded documents with DBRefs.
Replace embedded documents with DBRefs.
Replace embedded documents with DBRefs .
def transform_incoming(self, son, collection):
        """Replace embedded documents with DBRefs.
        """

        def transform_value(value):
            if isinstance(value, collections.MutableMapping):
                if "_id" in value and "_ns" in value:
                    return DBRef(value["_ns"], transform_value(value["_id"]))
                else:
                    return transform_dict(SON(value))
            elif isinstance(value, list):
                return [transform_value(v) for v in value]
            return value

        def transform_dict(object):
            for (key, value) in object.items():
                object[key] = transform_value(value)
            return object

        return transform_dict(SON(son))
def transform_incoming ( self , son , collection ) : def transform_value ( value ) : if isinstance ( value , collections . MutableMapping ) : if "_id" in value and "_ns" in value : return DBRef ( value [ "_ns" ] , transform_value ( value [ "_id" ] ) ) else : return transform_dict ( SON ( value ) ) elif isinstance ( value , list ) : return [ transform_value ( v ) for v in value ] return value def transform_dict ( object ) : for ( key , value ) in object . items ( ) : object [ key ] = transform_value ( value ) return object return transform_dict ( SON ( son ) )