# Path: solace/signals.py
# def _ref(func):
#     def __init__(self, im_self, im_func, im_class):
#     def resolve(self):
# def SIG(name, args=None):
#     def __init__(self, name, args=None, _frm=None):
#     def connect(self, func):
#     def is_connected(self, func):
#     def get_connections(self):
#     def disconnect(self, func):
#     def emit(self, **args):
#     def __reduce__(self):
#     def __repr__(self):
#     def emit(self, **args):
# def temporary_connection(func, signal):
# def handler(signal):
#     def decorator(func):
# class _MethodRef(object):
# class Signal(object):
# class _BroadcastSignal(Signal):


from werkzeug import Local, LocalManager
from solace.signals import after_request_shutdown
# -*- coding: utf-8 -*-
"""
    solace.utils.ctxlocal
    ~~~~~~~~~~~~~~~~~~~~~

    The context local that is used in the application and i18n system.  The
    application makes this request-bound.

    :copyright: (c) 2010 by the Solace Team, see AUTHORS for more details.
    :license: BSD, see LICENSE for more details.
"""


local = Local()
local_mgr = LocalManager([local])


class LocalProperty(object):
    """Class/Instance property that returns something from the local."""

    def __init__(self, name):
        self.__name__ = name

    def __get__(self, obj, type=None):
        return getattr(local, self.__name__, None)


# make sure the request local is removed at the end of the request

# Path: solace/signals.py
# def _ref(func):
#     def __init__(self, im_self, im_func, im_class):
#     def resolve(self):
# def SIG(name, args=None):
#     def __init__(self, name, args=None, _frm=None):
#     def connect(self, func):
#     def is_connected(self, func):
#     def get_connections(self):
#     def disconnect(self, func):
#     def emit(self, **args):
#     def __reduce__(self):
#     def __repr__(self):
#     def emit(self, **args):
# def temporary_connection(func, signal):
# def handler(signal):
#     def decorator(func):
# class _MethodRef(object):
# class Signal(object):
# class _BroadcastSignal(Signal):


# Path: solace/utils/ctxlocal.py
from werkzeug import Local, LocalManager
from solace.signals import after_request_shutdown

# -*- coding: utf-8 -*-
"""
    solace.utils.ctxlocal
    ~~~~~~~~~~~~~~~~~~~~~

    The context local that is used in the application and i18n system.  The
    application makes this request-bound.

    :copyright: (c) 2010 by the Solace Team, see AUTHORS for more details.
    :license: BSD, see LICENSE for more details.
"""


local = Local()
local_mgr = LocalManager([local])


class LocalProperty(object):
    """Class/Instance property that returns something from the local."""

    def __init__(self, name):
        self.__name__ = name

    def __get__(self, obj, type=None):
        return getattr(local, self.__name__, None)


# make sure the request local is removed at the end of the request

after_request_shutdown.connect(local_mgr.cleanup)