def __init__(self, config=None): """Create a WSGI server for providing OLAP web service. You might provide ``config`` as ``ConfigParser`` object. """ self.config = config self.initialize_logger() self.context = create_slicer_context(config) self.model = self.context["model"] self.locales = self.context["locales"] self.backend = self.context["backend"] self.model_localizations = {} if self.locales is None: if self.model.locale: self.locales = [self.model.locale] else: self.locales = [] ## Create workspace self.logger.info("using backend '%s'" % self.context["backend_name"]) self.workspace = self.backend.create_workspace(self.model, **self.context["workspace_options"])
def __init__(self, config=None): """Create a WSGI server for providing OLAP web service. You might provide ``config`` as ``ConfigParser`` object. """ self.config = config # # Configure logger # self.logger = cubes.common.get_logger() if self.config.has_option("server", "log"): formatter = logging.Formatter(fmt="%(asctime)s %(levelname)s %(message)s") handler = logging.FileHandler(self.config.get("server", "log")) handler.setFormatter(formatter) self.logger.addHandler(handler) if self.config.has_option("server", "log_level"): level_str = self.config.get("server", "log_level").lower() levels = {"info": logging.INFO, "debug": logging.DEBUG, "warn": logging.WARN, "error": logging.ERROR} if level_str not in levels: self.logger.warn("Unknown logging level '%s', keeping default" % level_str) else: self.logger.setLevel(levels[level_str]) self.logger.debug("loading model") context = create_slicer_context(config) self.model = context["model"] self.locales = context["locales"] self.backend = context["backend"] self.model_localizations = {} if self.locales is None: if self.model.locale: self.locales = [self.model.locale] else: self.locales = [] ## # Create workspace ## self.logger.info("using backend '%s'" % context["backend_name"]) self.workspace = self.backend.create_workspace(self.model, **context["workspace_options"])