コード例 #1
0
    def deserialize(self, cstruct=null):
        if cstruct is null:
            return null

        schema_type = self._deserialize_type(cstruct)
        subschema = self._build_schema(schema_type)
        return MappingSchema.deserialize(subschema, cstruct)
コード例 #2
0
    def deserialize(self, cstruct=null):
        if cstruct is null:
            return null

        schema_type = self._deserialize_type(cstruct)
        subschema = self._build_schema(schema_type)
        return MappingSchema.deserialize(subschema, cstruct)
コード例 #3
0
ファイル: views.py プロジェクト: robx/adhocracy3.mercator
def _validate_dict_schema(schema: MappingSchema, cstruct: dict,
                          request: Request, location='body'):
    validated = {}
    try:
        validated = schema.deserialize(cstruct)
    except Invalid as err:
        for child in err.children:
            _add_colander_invalid_error_to_request(child, request, location)
    request.validated.update(validated)
コード例 #4
0
    def _deserialize_type(self, cstruct):
        """
        Get the type of the entity based on `cstruct`.
        """
        # Build a schema containing only the type key.
        type_schema = MappingSchema()
        type_schema[self.type_key] = self[self.type_key]
        # Assign the proper name to the subschema so that
        # Invalid exceptions contains the right hierarchy.
        type_schema.name = self.name

        return type_schema.deserialize(cstruct)[self.type_key]
コード例 #5
0
    def _deserialize_type(self, cstruct):
        """
        Get the type of the entity based on `cstruct`.
        """
        # Build a schema containing only the type key.
        type_schema = MappingSchema()
        type_schema[self.type_key] = self[self.type_key]
        # Assign the proper name to the subschema so that
        # Invalid exceptions contains the right hierarchy.
        type_schema.name = self.name

        return type_schema.deserialize(cstruct)[self.type_key]
コード例 #6
0
ファイル: views.py プロジェクト: fhartwig/adhocracy3.mercator
def _validate_dict_schema(schema: MappingSchema,
                          cstruct: dict,
                          request: Request,
                          location='body'):
    validated = {}
    try:
        validated = schema.deserialize(cstruct)
    except Invalid as err:
        for child in err.children:
            _add_colander_invalid_error_to_request(child, request, location)
        if not err.children:
            _add_colander_invalid_error_to_request(err, request, location)
    request.validated.update(validated)
コード例 #7
0
ファイル: validationapp.py プロジェクト: doctaweeks/cornice
 def deserialize(self, cstruct):
     if 'field' in cstruct and not isinstance(cstruct['field'], list):
         cstruct['field'] = [cstruct['field']]
     return MappingSchema.deserialize(self, cstruct)
コード例 #8
0
ファイル: validationapp.py プロジェクト: doctaweeks/cornice
        def deserialize(self, cstruct):
            if 'body' in cstruct and cstruct['body'] == b'hello,open,yeah':
                values = cstruct['body'].decode().split(',')
                cstruct['body'] = dict(zip(['foo', 'bar', 'yeah'], values))

            return MappingSchema.deserialize(self, cstruct)
コード例 #9
0
 def deserialize(self, cstruct):
     if 'field' in cstruct and not isinstance(cstruct['field'], list):
         cstruct['field'] = [cstruct['field']]
     return MappingSchema.deserialize(self, cstruct)
コード例 #10
0
        def deserialize(self, cstruct):
            if 'body' in cstruct and cstruct['body'] == b'hello,open,yeah':
                values = cstruct['body'].decode().split(',')
                cstruct['body'] = dict(zip(['foo', 'bar', 'yeah'], values))

            return MappingSchema.deserialize(self, cstruct)