示例#1
0
def init_application(dbconf=None,cusconf=None,secret=None):
    log.startLogging(sys.stdout)  
    base.update_secret(secret)
    utils.update_secret(secret)
    log.msg("start init application...")
    TEMPLATE_PATH.append("./customer/views/")
    ''' install plugins'''
    engine,metadata = models.get_engine(dbconf)
    sqla_pg = sqla_plugin.Plugin(engine,metadata,keyword='db',create=False,commit=False,use_kwargs=False)
    session = sqla_pg.new_session()
    _sys_param_value = functools.partial(get_param_value,session)
    _get_member_by_name = functools.partial(get_member_by_name,session)
    _get_account_by_number = functools.partial(get_account_by_number,session)
    _get_online_status = functools.partial(get_online_status,session)
    MakoTemplate.defaults.update(**dict(
        get_cookie = get_cookie,
        fen2yuan = utils.fen2yuan,
        fmt_second = utils.fmt_second,
        request = request,
        sys_param_value = _sys_param_value,
        system_name = _sys_param_value("2_member_system_name"),
        get_member = _get_member_by_name,
        get_account = _get_account_by_number,
        is_online = _get_online_status
    ))

    websock.connect(
        _sys_param_value('3_radiusd_address'),
        _sys_param_value('4_radiusd_admin_port')
    )
    
    mainapp.install(sqla_pg)
示例#2
0
def init_application(dbconf=None,consconf=None,secret=None):
    log.startLogging(sys.stdout)  
    log.msg("start init application...")
    base.update_secret(secret)
    utils.update_secret(secret)
    TEMPLATE_PATH.append("./admin/views/")
    ''' install plugins'''
    log.msg("init plugins..")
    engine,metadata = models.get_engine(dbconf)
    sqla_pg = sqla_plugin.Plugin(engine,metadata,keyword='db',create=False,commit=False,use_kwargs=False)
    session = sqla_pg.new_session()
    _sys_param_value = functools.partial(get_param_value,session)
    _get_product_name = functools.partial(get_product_name,session)
    log.msg("init template context...")
    MakoTemplate.defaults.update(**dict(
        get_cookie = get_cookie,
        fen2yuan = utils.fen2yuan,
        fmt_second = utils.fmt_second,
        currdate = utils.get_currdate,
        request = request,
        sys_param_value = _sys_param_value,
        get_product_name = _get_product_name,
        system_name = _sys_param_value("1_system_name"),
        radaddr = _sys_param_value('3_radiusd_address'),
        adminport = _sys_param_value('4_radiusd_admin_port'),
        permit = permit,
        all_menus = permit.build_menus(order_cats=[u"系统管理",u"营业管理",u"运维管理"])
    ))
    
    # connect radiusd websocket admin port 
    log.msg("init websocket client...")
    wsparam = (MakoTemplate.defaults['radaddr'],MakoTemplate.defaults['adminport'],)
    reactor.callLater(3, websock.connect,*wsparam)
    log.msg("init tasks...")
    reactor.callLater(5, tasks.start_online_stat_job, sqla_pg.new_session)
   
    log.msg("init operator rules...")
    for _super in session.query(models.SlcOperator.operator_name).filter_by(operator_type=0):
        permit.bind_super(_super[0])

    log.msg("install plugins...")
    mainapp.install(sqla_pg)
    ops_app.install(sqla_pg)
    bus_app.install(sqla_pg)
    card_app.install(sqla_pg)

    mainapp.mount("/ops",ops_app)
    mainapp.mount("/bus",bus_app)
    mainapp.mount("/card",card_app)
    
    #create dir
    try:os.makedirs(os.path.join(APP_DIR,'static/xls'))
    except:pass
示例#3
0
def init_application(dbconf=None, consconf=None, secret=None):
    log.startLogging(sys.stdout)
    log.msg("start init application...")
    base.update_secret(secret)
    utils.update_secret(secret)
    TEMPLATE_PATH.append("./admin/views/")
    ''' install plugins'''
    log.msg("init plugins..")
    engine, metadata = models.get_engine(dbconf)
    sqla_pg = sqla_plugin.Plugin(engine,
                                 metadata,
                                 keyword='db',
                                 create=False,
                                 commit=False,
                                 use_kwargs=False)
    session = sqla_pg.new_session()
    _sys_param_value = functools.partial(get_param_value, session)
    _get_product_name = functools.partial(get_product_name, session)
    log.msg("init template context...")
    MakoTemplate.defaults.update(
        **dict(get_cookie=get_cookie,
               fen2yuan=utils.fen2yuan,
               fmt_second=utils.fmt_second,
               currdate=utils.get_currdate,
               request=request,
               sys_param_value=_sys_param_value,
               get_product_name=_get_product_name,
               system_name=_sys_param_value("1_system_name"),
               radaddr=_sys_param_value('3_radiusd_address'),
               adminport=_sys_param_value('4_radiusd_admin_port'),
               permit=permit,
               all_menus=permit.build_menus(
                   order_cats=[u"系统管理", u"营业管理", u"运维管理"])))

    # connect radiusd websocket admin port
    log.msg("init websocket client...")
    wsparam = (
        MakoTemplate.defaults['radaddr'],
        MakoTemplate.defaults['adminport'],
    )
    reactor.callLater(3, websock.connect, *wsparam)
    log.msg("init tasks...")
    reactor.callLater(5, tasks.start_online_stat_job, sqla_pg.new_session)

    log.msg("init operator rules...")
    for _super in session.query(
            models.SlcOperator.operator_name).filter_by(operator_type=0):
        permit.bind_super(_super[0])

    log.msg("install plugins...")
    mainapp.install(sqla_pg)
    ops_app.install(sqla_pg)
    bus_app.install(sqla_pg)
    card_app.install(sqla_pg)

    mainapp.mount("/ops", ops_app)
    mainapp.mount("/bus", bus_app)
    mainapp.mount("/card", card_app)

    #create dir
    try:
        os.makedirs(os.path.join(APP_DIR, 'static/xls'))
    except:
        pass