from ..core import * from ..oms import Oms class MemoryOms(Oms): def __init__(self): self.__current_tenant = None self.__instances = dict() self.__tenants = dict() def get_instance_by_key(self, key : InstanceKey): return self.__instances[key.to_tuple()] # def get_instance_by_global_identifier(self, global_identifier : Guid): def create_tenant(self, tenant_name : str): if tenant_name in self.__tenants: raise NameError("tenant with specified name already exists") self.__tenants[tenant_name] = TenantReference(tenant_name, None) def select_tenant(self, tenant : TenantReference): self.__current_tenant = tenant def release_tenant(self): self.__current_tenant = None def get_current_tenant(self): return self.__current_tenant def get_tenant_by_name(self, tenant_name : str): if tenant_name in self.__tenants: return self.__tenants[tenant_name] return None