Esempio n. 1
0
    def __init__(self, bundle_factory):
        """ initialize redis """
        config = bundle_factory.component.technical.config(bundle_factory())
        if not interface.technical.config.IConfig.providedBy(config):
            raise Exception('invalid configuration center')

        bundle_factory.dependent.redis = implement.technical.Dummy()
        bundle_factory.dependent.redis.engine = redis.Redis(
            host=config.get_value('redis_host') or '127.0.0.1',
            port=config.get_value('redis_port') or '6379',
            password=config.get_value('redis_pwd') or '2v0eps4o')
Esempio n. 2
0
    def __init__(self, **kwargs):
        config = kwargs.get('config')
        if not interface.technical.config.IConfig.providedBy(config):
            raise Exception('bundle should be initialized by config center')

        self.component.technical = implement.technical.Dummy()
        self.component.extension = implement.technical.Dummy()

        ''' check running options '''
        self.option.debug = (kwargs.get('debug') and True) or False

        ''' get sqlalchemy configuration string '''
        sal_conn = config.get_value('sal_conn')
        if sal_conn:
            ''' initialize database '''
            self.dependent.sa = implement.technical.Dummy()
            self.dependent.sa.engine = sqlalchemy.create_engine(
                sal_conn, echo=self.option.debug, pool_size=2, pool_recycle=3600)
            self.dependent.sa.session_maker = sqlalchemy.orm.scoped_session(
                sqlalchemy.orm.sessionmaker(bind=self.dependent.sa.engine, autocommit=True))