示例#1
0
    def __init_session_driver(self):
        """
        setup session driver.
        """
        self.__init_settings()

        driver = self.settings.get("driver")
        if not driver: raise SessionConfigurationError('driver not found')
        driver_settings = self.settings.get("driver_settings", {})
        if not driver_settings:
            raise SessionConfigurationError('driver settings not found.')

        cache_driver = self.settings.get("cache_driver", True)
        if cache_driver:
            cache_name = '__cached_session_driver'
            cache_handler = self.handler.application
            if not hasattr(cache_handler, cache_name):
                setattr(
                    cache_handler, cache_name,
                    SessionDriverFactory.create_driver(driver,
                                                       **driver_settings))
            session_driver = getattr(cache_handler, cache_name)
        else:
            session_driver = SessionDriverFactory.create_driver(
                driver, driver_settings)
        self.driver = session_driver(
            **driver_settings)  # create session driver instance.
示例#2
0
文件: session.py 项目: 0ps/Minos
 def __get_session_driver(self):
     driver_name = self.setting.get("driver")
     cache_driver = self.settings.get("cache_driver", True)
     driver_settings = self.settings.get("driver_settings", {})
     if cache_driver:
         cache_name = '__cached_session_driver'
         if not hasattr( self.handler.application, cache_name):
             if not driver_name:raise SessionConfigurationError('driver missed')
             if not driver_settings: raise SessionConfigurationError('driver settings missed.')
             setattr( self.handler.application, cache_name, SessionDriverFactory.create_driver(driver_name, **driver_settings))
         driver = getattr(self.hanlder.application, cache_name)
     else:
         driver = SessionDriverFactory.create_driver(driver_name, **driver_settings)
     return driver
示例#3
0
 def __get_session_driver(self):
     driver_name = self.setting.get("driver")
     cache_driver = self.settings.get("cache_driver", True)
     driver_settings = self.settings.get("driver_settings", {})
     if cache_driver:
         cache_name = '__cached_session_driver'
         if not hasattr(self.handler.application, cache_name):
             if not driver_name:
                 raise SessionConfigurationError('driver missed')
             if not driver_settings:
                 raise SessionConfigurationError('driver settings missed.')
             setattr(
                 self.handler.application, cache_name,
                 SessionDriverFactory.create_driver(driver_name,
                                                    **driver_settings))
         driver = getattr(self.hanlder.application, cache_name)
     else:
         driver = SessionDriverFactory.create_driver(
             driver_name, **driver_settings)
     return driver
示例#4
0
文件: session.py 项目: 0ps/Minos
    def __init_session_driver(self):
        """
        setup session driver.
        """
        self.__init_settings()

        driver = self.settings.get("driver")
        if not driver: raise SessionConfigurationError('driver not found')
        driver_settings = self.settings.get("driver_settings", {})
        if not driver_settings: raise SessionConfigurationError('driver settings not found.')

        cache_driver = self.settings.get("cache_driver", True)
        if cache_driver:
            cache_name = '__cached_session_driver'
            cache_handler = self.handler.application
            if not hasattr(cache_handler, cache_name):
                setattr(cache_handler, cache_name, SessionDriverFactory.create_driver(driver, **driver_settings))
            session_driver = getattr(cache_handler, cache_name)
        else:
            session_driver = SessionDriverFactory.create_driver(driver, driver_settings)
        self.driver = session_driver(**driver_settings) # create session driver instance.