def METHOD_NAME(doc, varname, default=None):
    """Get a single value from the document.
    If a default is given and the type is bool or int, the value is converted to the same type.
    If no value exists, the default is returned.
    """
    variables = manager(doc).variables()
    try:
        return prepare(variables[varname], default)
    except KeyError:
        return default