Example #1
0
def taxonomy_term_show(context, data_dict):
    """
    Shows a single taxonomy term and its children, the taxonomy id is not
    required, just a term_id.

    :returns: A single taxonomy term
    :rtype: A dictionary
    """
    _check_access('taxonomy_term_show', context, data_dict)

    id = data_dict.get('id')
    uri = data_dict.get('uri')
    label = data_dict.get('label')
    taxonomy_id = data_dict.get('taxonomy_id')

    if not id and not uri and not label:
        raise logic.ValidationError("Either id, uri or label is required")

    if (taxonomy_id):
        term = TaxonomyTerm.get_from_taxonomy(id or uri or label, taxonomy_id)
    else:
        term = TaxonomyTerm.getnew(id or uri or label)

    if not term:
        raise logic.NotFound()

    return term.as_dict()