Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_backend_bykind(self, kind, model_store=None, data_store=None,
**kwargs):
"""
return the backend by a given object kind
:param kind: The object kind
:param model_store: the OmegaStore instance used to store models
:param data_store: the OmegaStore instance used to store data
:param kwargs: the kwargs passed to the backend initialization
:return: the backend
"""
try:
backend_cls = load_class(self.defaults.OMEGA_STORE_BACKENDS[kind])
except:
raise ValueError('backend {kind} does not exist'.forma(**locals()))
model_store = model_store or self
data_store = data_store or self
backend = backend_cls(model_store=model_store,
data_store=data_store, **kwargs)
return backend
def register_backend(self, kind, backend):
"""
register a backend class
:param kind: (str) the backend kind
:param backend: (class) the backend class
"""
self.defaults.OMEGA_STORE_BACKENDS[kind] = load_class(backend)
if kind not in MDREGISTRY.KINDS:
MDREGISTRY.KINDS.append(kind)
return self