def dict_payload_parser(accessor, fields):
    """Parse an object to generate a payload.

    @accesor takes in object and a field name and gets a value.
    @fields is a dict mapping from field names in the payload to field names in
    the object.
    """
    def parse_object(obj):
        return { field_name: accessor(obj, fields[field_name])
                for field_name in fields }

    return parse_object