# Path: pyfire/auth/registry.py
# class ValidationRegistry(object):
#     """Holds all active validation backends"""
# 
#     def __init__(self):
#         self.handlers = {}
#         self._lock = allocate_lock()
# 
#     def register(self, backend, handler):
#         """Registers given backend handler"""
# 
#         success = False
#         with self._lock:
#             if backend not in self.handlers:
#                 self.handlers[backend] = handler
#                 success = True
#         if not success:
#             raise AttributeError("backend already known")
# 
#     def unregister(self, backend):
#         """Unregisters handler for backend"""
# 
#         success = False
#         with self._lock:
#             if backend in self.handlers:
#                 self.handlers[backend].shutdown()
#                 del self.handlers[backend]
#                 success = True
#         if not success:
#             raise AttributeError("backend unknown")
# 
#     def validate_userpass(self, username, password):
#         """Checks username and password against all backends. Returns
#            backend name where backend reported OK or raises
#            InvalidAuthenticationError otherwise.
#         """
# 
#         result = ""
#         with self._lock:
#             for backend, handler in self.handlers.iteritems():
#                 if handler.validate_userpass(username, password):
#                     result = backend
#                     break
#         if result == "":
#             raise InvalidAuthenticationError("username/password invalid")
#         return result
# 
#     def validate_token(self, token):
#         """Validates given token against all backends. Returns
#            backend name where backend reported OK or raises
#            InvalidAuthenticationError otherwise.
#         """
# 
#         result = ""
#         with self._lock:
#             for backend, handler in self.handlers.iteritems():
#                 if handler.validate_token(token):
#                     result = backend
#                     break
#         if result == "":
#             raise InvalidAuthenticationError("token invalid")
#         return result
# 
# Path: pyfire/logger.py
# class Logger(logbook.Logger):
#     def __init__(self, name):
#         classname = name.replace('.', '_').lower()
#         if classname.startswith("pyfire_"):
#             classname = classname[7:]
# 
#         try:
#             level = config.get('logging', classname).upper()
#         except config.NoOptionError:
#             level = ''
# 
#         if not level:
#             level = config.get('logging', 'global_level').upper()
# 
#         if level not in frozenset(['CRITICAL', 'ERROR', 'WARNING',
#                                    'INFO', 'DEBUG', 'NOTSET']):
#             warnings.warn("No such loglevel %s" % level, RuntimeWarning)
#             level = 'ERROR'
#         super(Logger, self).__init__(classname, getattr(logbook, level))
#         self.handlers.append(logbook.more.ColorizedStderrHandler())
#         self._disabled = False
# 
#     def _set_disabled(self, value):
#         self._disabled = value
# 
#     def _get_disabled(self):
#         return global_disable or self._disabled
# 
#     disabled = property(_get_disabled, _set_disabled)


from thread import allocate_lock
from pyfire.auth.registry import ValidationRegistry
from pyfire.logger import Logger
import zmq
import pyfire.configuration as config
# -*- coding: utf-8 -*-
"""
    pyfire.singletons
    ~~~~~~~~~~~~~~~~~

    Contains all singleton classes we use

    :copyright: 2011 by the pyfire Team, see AUTHORS for more details.
    :license: BSD, see LICENSE for more details.
"""





# Path: pyfire/auth/registry.py
# class ValidationRegistry(object):
#     """Holds all active validation backends"""
# 
#     def __init__(self):
#         self.handlers = {}
#         self._lock = allocate_lock()
# 
#     def register(self, backend, handler):
#         """Registers given backend handler"""
# 
#         success = False
#         with self._lock:
#             if backend not in self.handlers:
#                 self.handlers[backend] = handler
#                 success = True
#         if not success:
#             raise AttributeError("backend already known")
# 
#     def unregister(self, backend):
#         """Unregisters handler for backend"""
# 
#         success = False
#         with self._lock:
#             if backend in self.handlers:
#                 self.handlers[backend].shutdown()
#                 del self.handlers[backend]
#                 success = True
#         if not success:
#             raise AttributeError("backend unknown")
# 
#     def validate_userpass(self, username, password):
#         """Checks username and password against all backends. Returns
#            backend name where backend reported OK or raises
#            InvalidAuthenticationError otherwise.
#         """
# 
#         result = ""
#         with self._lock:
#             for backend, handler in self.handlers.iteritems():
#                 if handler.validate_userpass(username, password):
#                     result = backend
#                     break
#         if result == "":
#             raise InvalidAuthenticationError("username/password invalid")
#         return result
# 
#     def validate_token(self, token):
#         """Validates given token against all backends. Returns
#            backend name where backend reported OK or raises
#            InvalidAuthenticationError otherwise.
#         """
# 
#         result = ""
#         with self._lock:
#             for backend, handler in self.handlers.iteritems():
#                 if handler.validate_token(token):
#                     result = backend
#                     break
#         if result == "":
#             raise InvalidAuthenticationError("token invalid")
#         return result
# 
# Path: pyfire/logger.py
# class Logger(logbook.Logger):
#     def __init__(self, name):
#         classname = name.replace('.', '_').lower()
#         if classname.startswith("pyfire_"):
#             classname = classname[7:]
# 
#         try:
#             level = config.get('logging', classname).upper()
#         except config.NoOptionError:
#             level = ''
# 
#         if not level:
#             level = config.get('logging', 'global_level').upper()
# 
#         if level not in frozenset(['CRITICAL', 'ERROR', 'WARNING',
#                                    'INFO', 'DEBUG', 'NOTSET']):
#             warnings.warn("No such loglevel %s" % level, RuntimeWarning)
#             level = 'ERROR'
#         super(Logger, self).__init__(classname, getattr(logbook, level))
#         self.handlers.append(logbook.more.ColorizedStderrHandler())
#         self._disabled = False
# 
#     def _set_disabled(self, value):
#         self._disabled = value
# 
#     def _get_disabled(self):
#         return global_disable or self._disabled
# 
#     disabled = property(_get_disabled, _set_disabled)


# Path: pyfire/singletons.py
from thread import allocate_lock
from pyfire.auth.registry import ValidationRegistry
from pyfire.logger import Logger
import zmq
import pyfire.configuration as config

# -*- coding: utf-8 -*-
"""
    pyfire.singletons
    ~~~~~~~~~~~~~~~~~

    Contains all singleton classes we use

    :copyright: 2011 by the pyfire Team, see AUTHORS for more details.
    :license: BSD, see LICENSE for more details.
"""





log = Logger(__name__)