A decorator that registers a single hug delete context function

def delete_context(apply_globally=False, api=None):
    """A decorator that registers a single hug delete context function"""
    def decorator(delete_context_):
        if apply_globally:
            hug.defaults.delete_context = delete_context_
        else:
            apply_to_api = hug.API(api) if api else hug.api.from_object(delete_context_)
            apply_to_api.delete_context = delete_context_
        return delete_context_
    return decorator