예제 #1
0
파일: batch.py 프로젝트: zeroyou/kinto
 def deserialize(self, cstruct=colander.null):
     """Preprocess received data to carefully merge defaults."""
     if cstruct is not colander.null:
         defaults = cstruct.get("defaults")
         requests = cstruct.get("requests")
         if isinstance(defaults, dict) and isinstance(requests, list):
             for request in requests:
                 if isinstance(request, dict):
                     merge_dicts(request, defaults)
     return super().deserialize(cstruct)
예제 #2
0
파일: batch.py 프로젝트: pmker/kinto
 def deserialize(self, cstruct=colander.null):
     """Preprocess received data to carefully merge defaults.
     """
     defaults = cstruct.get('defaults')
     requests = cstruct.get('requests')
     if isinstance(defaults, dict) and isinstance(requests, list):
         for request in requests:
             if isinstance(request, dict):
                 merge_dicts(request, defaults)
     return super(BatchPayloadSchema, self).deserialize(cstruct)
예제 #3
0
파일: batch.py 프로젝트: glasserc/kinto
 def deserialize(self, cstruct=colander.null):
     """Preprocess received data to carefully merge defaults.
     """
     if cstruct is not colander.null:
         defaults = cstruct.get('defaults')
         requests = cstruct.get('requests')
         if isinstance(defaults, dict) and isinstance(requests, list):
             for request in requests:
                 if isinstance(request, dict):
                     merge_dicts(request, defaults)
     return super().deserialize(cstruct)
예제 #4
0
파일: batch.py 프로젝트: zeddmaxx/kinto
    def unflatten(self, data):
        """Preprocess received data to merge defaults.

        Override schema unflattening to plug into Cornice schema validation.
        This is the only method that Cornice calls at the schema level before
        iterating on each field to deserialize them.
        """
        # On defaults, path is not mandatory.
        self.get('defaults').get('path').missing = colander.drop

        # Fill requests values with defaults.
        requests = data.get('requests', [])
        for request in requests:
            defaults = data.get('defaults')
            if isinstance(defaults, dict):
                merge_dicts(request, defaults)

        return data
예제 #5
0
파일: batch.py 프로젝트: DarkDare/kinto
    def unflatten(self, data):
        """Preprocess received data to merge defaults.

        Override schema unflattening to plug into Cornice schema validation.
        This is the only method that Cornice calls at the schema level before
        iterating on each field to deserialize them.
        """
        # On defaults, path is not mandatory.
        self.get('defaults').get('path').missing = colander.drop

        # Fill requests values with defaults.
        requests = data.get('requests', [])
        for request in requests:
            defaults = data.get('defaults')
            if isinstance(defaults, dict):
                merge_dicts(request, defaults)

        return data