'Use data in `expected_param_data` to parse `query_param` from a string into
a resource usable directly by a template.'

def parse_parameter(self, trans, expected_param_data, query_param, recurse=True, param_modifiers=None):

    param_type = expected_param_data.get('type')
    csv = expected_param_data.get('csv')
    parsed_param = None
    if (csv and recurse):
        parsed_param = []
        query_param_list = galaxy.util.listify(query_param)
        for query_param in query_param_list:
            parsed_param.append(self._parse_param(trans, expected_param_data, query_param, recurse=False))
        return parsed_param
    if (param_type in self.primitive_parsers):
        parsed_param = self.primitive_parsers[param_type](query_param)
    elif (param_type == 'visualization'):
        decoded_visualization_id = self._decode_id(query_param)
        parsed_param = self.managers.visualization.get_accessible(decoded_visualization_id, trans.user)
    elif (param_type == 'dataset'):
        decoded_dataset_id = self._decode_id(query_param)
        parsed_param = self.managers.hda.get_accessible(decoded_dataset_id, trans.user)
    elif (param_type == 'hda_or_ldda'):
        encoded_dataset_id = query_param
        hda_ldda = param_modifiers.get('hda_ldda')
        if (hda_ldda == 'hda'):
            decoded_dataset_id = self._decode_id(encoded_dataset_id)
            parsed_param = self.managers.hda.get_accessible(decoded_dataset_id, trans.user)
        else:
            parsed_param = self.managers.ldda.get(trans, encoded_dataset_id)
    elif (param_type == 'dbkey'):
        dbkey = query_param
        parsed_param = galaxy.util.sanitize_html.sanitize_html(dbkey, 'utf-8')
    return parsed_param
