# Path: torext/utils.py
# class SingletonMixin(object):
#     """Globally hold one instance class
# 
#     Usage:
#     >>> class SpecObject(SingletonMixin):
#     ...     pass
# 
#     >>> ins = SpecObject.instance()
#     """
#     @classmethod
#     def instance(cls, *args, **kwgs):
#         """Will be the only instance"""
#         if not hasattr(cls, "_instance"):
#             cls._instance = cls(*args, **kwgs)
#         return cls._instance
# 
# Path: torext/errors.py
# class SettingsError(TorextException):
#     pass
# 
# Path: torext/log.py
# def set_loggers(loggers):
#     for name, config in loggers.items():
#         set_logger(name, **config)


from torext.utils import SingletonMixin
from torext.errors import SettingsError
from torext.log import set_loggers
        from torext import base_settings
    by import torext module, a Settings object will be instanced and stored globally,
    then it can be involved in any place like this:
    >>> import torext
    >>> print torext.settings
    or
    >>> from torext import settings
    >>> print settings

    getting value from settings is like from a normal dict:
    >>> settings['DEBUG']
    True
    >>> settings.get('PORT')
    8000
    >>> settings.get('WTF', None)
    None

    notice that you can use lower case word to get or set the value:
    >>> settings['debug'] is settings.get('DEBUG')
    True
    >>> settings['port'] = 8765
    >>> settings['PORT']
    8765

    TODO require_setting
    """
    def __init__(self):
        """
        Setting definitions in base_settings are indispensable
        """
        self._callbacks = {}

# Path: torext/utils.py
# class SingletonMixin(object):
#     """Globally hold one instance class
# 
#     Usage:
#     >>> class SpecObject(SingletonMixin):
#     ...     pass
# 
#     >>> ins = SpecObject.instance()
#     """
#     @classmethod
#     def instance(cls, *args, **kwgs):
#         """Will be the only instance"""
#         if not hasattr(cls, "_instance"):
#             cls._instance = cls(*args, **kwgs)
#         return cls._instance
# 
# Path: torext/errors.py
# class SettingsError(TorextException):
#     pass
# 
# Path: torext/log.py
# def set_loggers(loggers):
#     for name, config in loggers.items():
#         set_logger(name, **config)


# Path: torext/make_settings.py
from torext.utils import SingletonMixin
from torext.errors import SettingsError
from torext.log import set_loggers
        from torext import base_settings

    by import torext module, a Settings object will be instanced and stored globally,
    then it can be involved in any place like this:
    >>> import torext
    >>> print torext.settings
    or
    >>> from torext import settings
    >>> print settings

    getting value from settings is like from a normal dict:
    >>> settings['DEBUG']
    True
    >>> settings.get('PORT')
    8000
    >>> settings.get('WTF', None)
    None

    notice that you can use lower case word to get or set the value:
    >>> settings['debug'] is settings.get('DEBUG')
    True
    >>> settings['port'] = 8765
    >>> settings['PORT']
    8765

    TODO require_setting
    """
    def __init__(self):
        """
        Setting definitions in base_settings are indispensable
        """
        self._callbacks = {}

        self.add_key_callback('LOGGERS', set_loggers)