示例#1
0
def reorder_type_info(fields, type_info, allow_partial=False):
    """
    re-order the given type_info into the order given with fields. Anything
    not mentioned in fields, will be appended last.
    """

    copy = TypeInfo(type_info.items())
    new = TypeInfo()
    for field in fields:
        if field not in copy:
            if allow_partial:
                # If we order the <gelijk> element, this element can contain far less elements than the <object>
                # element. This is a workaround by assuming the gelijk-order it the same as the object-order.
                continue
            else:
                raise KeyError(
                    'All fields must be present in the Spyne model: {} is missing.'
                    .format(field))

        value = copy[field]
        del copy[field]
        new[field] = value

    # Add the fields not specified in fields last.
    for field, value in copy.items():
        new[field] = value
    return new
def reorder_type_info(fields, type_info, allow_partial=False):
    """
    re-order the given type_info into the order given with fields. Anything
    not mentioned in fields, will be appended last.
    """

    copy = TypeInfo(type_info.items())
    new = TypeInfo()
    for field in fields:
        if field not in copy:
            if allow_partial:
                # If we order the <gelijk> element, this element can contain far less elements than the <object>
                # element. This is a workaround by assuming the gelijk-order it the same as the object-order.
                continue
            else:
                raise KeyError('All fields must be present in the Spyne model: {} is missing.'.format(field))

        value = copy[field]
        del copy[field]
        new[field] = value

    # Add the fields not specified in fields last.
    for field, value in copy.items():
        new[field] = value
    return new
    def reorder_type_info(self, fields, type_info):
        """
        re-order the given type_info into the order given with fields. Anything
        not mentioned in fields, will be appended last.
        """

        copy = TypeInfo(type_info.items())
        new = TypeInfo()
        for field in fields:
            value = copy[field]
            del copy[field]
            new[field] = value

        # Add the fields not specified in fields last.
        for field, value in copy.items():
            new[field] = value
        return new
示例#4
0
    def reorder_type_info(self, fields, type_info):
        """
        re-order the given type_info into the order given with fields. Anything
        not mentioned in fields, will be appended last.
        """

        copy = TypeInfo(type_info.items())
        new = TypeInfo()
        for field in fields:
            value = copy[field]
            del copy[field]
            new[field] = value

        # Add the fields not specified in fields last.
        for field, value in copy.items():
            new[field] = value
        return new