Exemple #1
0
 def __init__(self, handler, store, config=session_parameters):
     self._get_cookie = handler.get_cookie
     self._set_cookie = handler.set_cookie
     self.remote_ip = handler.request.remote_ip
     self.store = store
     self.config = storage(config)
     self._data = {}
    def __getattr__(self, item):
        setting = _Settings.settings_object()
        if hasattr(setting, item):
            config = getattr(setting, item)
        else:
            raise ConfigError('settings "%s" not exist!' % item)

        return storage(config) if type(config) is dict else config
    def __getattr__(self, item):
        setting = _Settings.settings_object()
        if hasattr(setting, item):
            config = getattr(setting, item)
        else:
            raise ConfigError('settings "%s" not exist!' % item)

        return storage(config) if type(config) is dict else config
Exemple #4
0
    def __init__(self, handler, store, config=None):
        self._get_cookie = handler.get_cookie
        self._set_cookie = handler.set_cookie
        self.remote_ip = handler.request.remote_ip
        self.store = store
        self.config = storage(session_parameters)
        if config:
            self.config.update(config)

        self._data = {}
Exemple #5
0
    def connetion(self):
        if hasattr(_SqlConnection, '_conn'):
            return _SqlConnection._conn
        else:
            with _SqlConnection._conn_lock:
                connection_pool = storage()
                connections = settings.DATABASE_CONNECTION
                try:
                    config = settings.SQLALCHEMY_CONFIGURATION
                except ConfigError, ex:
                    config = _BASE_SQLALCHEMY_CONFIGURATION

                for connection_name, connection_item in connections.items():
                    master = []
                    slaves = []
                    kwargs = connection_item.get('kwargs', {})
                    connections_str = connection_item['connections']

                    for conn in connections_str:
                        dburl = url.URL(drivername=conn['DRIVER']
                                        , username=conn['UID']
                                        , password=conn['PASSWD']
                                        , host=conn['HOST']
                                        , port=conn['PORT']
                                        , database=conn['DATABASE']
                                        , query=conn['QUERY'])

                        if conn['ROLE'] == _CONNECTION_TYPE[0]:
                            master.append(dburl)
                        else:
                            slaves.append(dburl)

                    if not len(master):
                        raise ConfigError('conn:%s ,master connection not found.' % connection_name)
                    try:
                        connection_pool[connection_name] = SQLAlchemy(config, master_url=master[0], slaves_url=slaves,
                                                                      **kwargs)
                    except Exception:
                        raise

                _SqlConnection._conn = connection_pool
            return _SqlConnection._conn
Exemple #6
0
    def process_response(self, handler, clear, chunk):
        if hasattr(handler, "session"):
            handler.session.save()
            del handler.session


_DAY1 = 24 * 60 * 60
_DAY30 = _DAY1 * 30

session_parameters = storage({
    'session_name': '__TORNADOSSID',
    'cookie_domain': None,
    'cookie_path': '/',
    'expires': 0,  # 24 * 60 * 60, # 24 hours in seconds
    'ignore_change_ip': False,
    'httponly': True,
    'secure': False,
    'secret_key': 'fLjUfxqXtfNoIldA0A0J',
    'session_version': ''
})


class SessionManager(object):
    _killed = False

    def __init__(self, handler, store, config=None):
        self._get_cookie = handler.get_cookie
        self._set_cookie = handler.set_cookie
        self.remote_ip = handler.request.remote_ip
        self.store = store
Exemple #7
0
    def process_response(self, handler, chunk=None):
        if hasattr(handler, "session"):
            handler.session.save()
            del handler.session


_DAY1 = 24 * 60 * 60
_DAY30 = _DAY1 * 30
_VERIFICATION_KEY = '__VERIFSSID'

session_parameters = storage({
    'session_name': '__TORNADOSSID',
    'cookie_domain': None,
    'cookie_path': '/',
    'expires': 0,  #24 * 60 * 60, # 24 hours in seconds
    'ignore_change_ip': False,
    'httponly': True,
    'secure': False,
    'secret_key': 'fLjUfxqXtfNoIldA0A0J',
    'session_version': ''
})


class SessionManager(object):
    _killed = False

    def __init__(self, handler, store, config=session_parameters):
        self._get_cookie = handler.get_cookie
        self._set_cookie = handler.set_cookie
        self.remote_ip = handler.request.remote_ip
        self.store = store
Exemple #8
0
        if hasattr(handler, "session"):
            handler.session.save()
            del handler.session


_DAY1 = 24 * 60 * 60
_DAY30 = _DAY1 * 30
_VERIFICATION_KEY = "__VERIFSSID"

session_parameters = storage(
    {
        "session_name": "__TORNADOSSID",
        "cookie_domain": None,
        "cookie_path": "/",
        "expires": 0,  # 24 * 60 * 60, # 24 hours in seconds
        "ignore_change_ip": False,
        "httponly": True,
        "secure": False,
        "secret_key": "fLjUfxqXtfNoIldA0A0J",
        "session_version": "",
    }
)


class SessionManager(object):
    _killed = False

    def __init__(self, handler, store, config=None):
        self._get_cookie = handler.get_cookie
        self._set_cookie = handler.set_cookie
        self.remote_ip = handler.request.remote_ip