def title_or_value(vocabulary, value):
    """
    Given a `vocabulary` and a `value` in that vocabulary, return the
    corresponding title or `value` if there is no title.
    """
    try:
        return vocabulary.getTerm(value).title or value
    except LookupError:
        return value
