def __init__(self, wok_options): make_dirs = [ os.path.dirname(os.path.abspath(config.get_object_store())), os.path.abspath(config.get_debugreports_path()) ] for directory in make_dirs: if not os.path.isdir(directory): os.makedirs(directory) if hasattr(wok_options, "model"): self.model = wok_options.model elif wok_options.test: self.model = mockmodel.MockModel() else: self.model = gingerBaseModel.Model() dev_env = wok_options.environment != 'production' super(GingerBase, self).__init__(self.model, dev_env) for ident, node in sub_nodes.items(): setattr(self, ident, node(self.model)) self.api_schema = json.load( open( os.path.join(os.path.dirname(os.path.abspath(__file__)), 'API.json'))) self.paths = config.gingerBasePaths self.domain = 'gingerbase' self.messages = messages
def __init__(self, wok_options): if hasattr(wok_options, "model"): self.model = wok_options.model elif wok_options.test: self.model = mockmodel.MockModel() else: self.model = gingerBaseModel.Model() dev_env = wok_options.environment != 'production' super(GingerBase, self).__init__(self.model, dev_env) for ident, node in sub_nodes.items(): setattr(self, ident, node(self.model)) self.api_schema = json.load(open(os.path.join(os.path.dirname( os.path.abspath(__file__)), 'API.json'))) self.paths = config.gingerBasePaths self.domain = 'gingerbase' self.messages = messages make_dirs = [ os.path.dirname(os.path.abspath(config.get_object_store())), os.path.abspath(config.get_debugreports_path()) ] for directory in make_dirs: if not os.path.isdir(directory): os.makedirs(directory)
def __init__(self, wok_options): make_dirs = [ os.path.dirname(os.path.abspath(config.get_object_store())), os.path.abspath(config.get_debugreports_path()) ] for directory in make_dirs: if not os.path.isdir(directory): os.makedirs(directory) if wok_options.test and (wok_options.test is True or wok_options.test.lower() == 'true'): self.objectstore_loc = tempfile.mktemp() self.model = mockmodel.MockModel(self.objectstore_loc) def remove_objectstore(): if os.path.exists(self.objectstore_loc): os.unlink(self.objectstore_loc) cherrypy.engine.subscribe('exit', remove_objectstore) else: self.model = gingerBaseModel.Model() dev_env = wok_options.environment != 'production' super(Gingerbase, self).__init__(self.model, dev_env) for ident, node in sub_nodes.items(): setattr(self, ident, node(self.model)) self.api_schema = json.load(open(os.path.join(os.path.dirname( os.path.abspath(__file__)), 'API.json'))) self.paths = config.gingerBasePaths self.domain = 'gingerbase' self.messages = messages
def __init__(self, objstore_loc=None): def get_instances(module_name): instances = [] module = import_module(module_name) members = inspect.getmembers(module, inspect.isclass) for cls_name, instance in members: if inspect.getmodule(instance) == module and \ cls_name.endswith('Model'): instances.append(instance) return instances if objstore_loc is None: objstore_loc = config.get_object_store() # Some paths or URI's present in the objectstore have changed after # Wok 2.0.0 release. Check here if a schema upgrade is necessary. upgrade_objectstore_schema(objstore_loc, 'version') self.objstore = ObjectStore(objstore_loc) kargs = {'objstore': self.objstore} models = [] # Import task model from Wok instances = get_instances('wok.model.tasks') for instance in instances: models.append(instance(**kargs)) # Import all Kimchi plugin models this = os.path.basename(__file__) this_mod = os.path.splitext(this)[0] for mod_name in listPathModules(os.path.dirname(__file__)): if mod_name.startswith("_") or mod_name == this_mod: continue instances = get_instances('wok.plugins.gingerbase.model.' + mod_name) for instance in instances: models.append(instance(**kargs)) return super(Model, self).__init__(models)
def __init__(self, objstore_loc=None): if objstore_loc is None: objstore_loc = config.get_object_store() # Some paths or URI's present in the objectstore have changed after # Wok 2.0.0 release. Check here if a schema upgrade is necessary. upgrade_objectstore_schema(objstore_loc, 'version') self.objstore = ObjectStore(objstore_loc) kargs = {'objstore': self.objstore} models = get_all_model_instances(__name__, __file__, kargs) # Import task model from Wok instances = get_model_instances('wok.model.tasks') for instance in instances: models.append(instance(**kargs)) return super(Model, self).__init__(models)
def __init__(self, objstore_loc=None): def get_instances(module_name): instances = [] module = import_module(module_name) members = inspect.getmembers(module, inspect.isclass) for cls_name, instance in members: if inspect.getmodule(instance) == module and \ cls_name.endswith('Model'): instances.append(instance) return instances if objstore_loc is None: objstore_loc = config.get_object_store() self.objstore = ObjectStore(objstore_loc) kargs = {'objstore': self.objstore} models = [] # Import task model from Wok instances = get_instances('wok.model.tasks') for instance in instances: models.append(instance(**kargs)) # Import all Kimchi plugin models this = os.path.basename(__file__) this_mod = os.path.splitext(this)[0] for mod_name in listPathModules(os.path.dirname(__file__)): if mod_name.startswith("_") or mod_name == this_mod: continue instances = get_instances('wok.plugins.gingerbase.model.' + mod_name) for instance in instances: models.append(instance(**kargs)) return super(Model, self).__init__(models)