def readattr(_obj, _name, _default=None, _error_on_none=None):
    """
    Reads an attribute value from an object
    :param _obj: The object
    :param _name: The name of the attribute
    :param _default: If set, the value to return if the attribute is missing or the value is None
    :param _error_on_none: If set, the message of an exception that is raised if the attribute is missing or the value is None
    :return: The value of the attribute
    """

    try:
        _value = getattr(_obj, _name)
    except AttributeError:
        if _error_on_none:
            raise Exception(_error_on_none)
        else:
            return _default

    if _value is None:
        if _error_on_none:
            raise Exception(_error_on_none)
        else:
            return _default
    else:
        return _value