def start(config_file, *args): # load config import yaml runtime_config = yaml.load(open(config_file)) or {} # update config for k, v in runtime_config.items(): setattr(config, k, v) # import plugins plugins = [] for p in config.get('plugins') or []: plugins.append(__import__(p, None, None, ["x"])) print >> web.debug, "loaded plugin", p web.config.db_parameters = parse_db_parameters(config.db_parameters) # initialize cache cache_params = config.get('cache', {'type': 'none'}) cache.global_cache = cache.create_cache(**cache_params) # init plugins for p in plugins: m = getattr(p, 'init_plugin', None) m and m() # start running the server sys.argv = [sys.argv[0]] + list(args) run()
def load_config(config_file): # load config import yaml runtime_config = yaml.load(open(config_file)) or {} # update config for k, v in runtime_config.items(): setattr(config, k, v) # import plugins plugins = [] for p in config.get('plugins') or []: plugins.append(__import__(p, None, None, ["x"])) logger.info("loading plugin %s", p) web.config.db_parameters = parse_db_parameters(config.db_parameters) # initialize cache cache_params = config.get('cache', {'type': 'none'}) cache.global_cache = cache.create_cache(**cache_params) # init plugins for p in plugins: m = getattr(p, 'init_plugin', None) m and m()
if web.ctx.get('infobase_localmode'): raise common.InfobaseException(message=str(e)) else: process_exception(e) if isinstance(d, JSON): result = d.json else: result = simplejson.dumps(d) t_end = time.time() totaltime = t_end - t_start querytime = web.ctx.pop('querytime', 0.0) queries = web.ctx.pop('queries', 0) if config.get("enabled_stats"): web.header( "X-STATS", "tt: %0.3f, tq: %0.3f, nq: %d" % (totaltime, querytime, queries)) if web.ctx.get('infobase_localmode'): return result else: # set auth-token as cookie for remote connection. if web.ctx.get('infobase_auth_token'): web.setcookie('infobase_auth_token', web.ctx.infobase_auth_token) return result return g
if web.ctx.get('infobase_localmode'): raise common.InfobaseException(message=str(e)) else: process_exception(e) if isinstance(d, JSON): result = d.json else: result = simplejson.dumps(d) t_end = time.time() totaltime = t_end - t_start querytime = web.ctx.pop('querytime', 0.0) queries = web.ctx.pop('queries', 0) if config.get("enabled_stats"): web.header("X-STATS", "tt: %0.3f, tq: %0.3f, nq: %d" % (totaltime, querytime, queries)) if web.ctx.get('infobase_localmode'): return result else: # set auth-token as cookie for remote connection. if web.ctx.get('infobase_auth_token'): web.setcookie('infobase_auth_token', web.ctx.infobase_auth_token) return result return g def get_data(): if 'infobase_input' in web.ctx: return web.ctx.infobase_input