From d7baf2f387191883a011c0816be13589b173f792 Mon Sep 17 00:00:00 2001 From: Ovidiu MIRCESCU Date: Thu, 4 Feb 2021 15:43:10 +0100 Subject: [PATCH] Generic creation of a sessionless component. --- src/KERNEL_PY/__init__.py | 43 ++++++--------------------------------- 1 file changed, 6 insertions(+), 37 deletions(-) diff --git a/src/KERNEL_PY/__init__.py b/src/KERNEL_PY/__init__.py index 8577a7dd2..1e458911e 100644 --- a/src/KERNEL_PY/__init__.py +++ b/src/KERNEL_PY/__init__.py @@ -182,43 +182,12 @@ def salome_init(path=None, embedded=False): class StandAloneLifecyle: def FindOrLoadComponent(self,contName,moduleName): global orb - if contName == "FactoryServer" and moduleName == "GEOM": - import GeomHelper - geom_ior = GeomHelper.BuildGEOMInstance() - import GEOM - import CORBA - orb=CORBA.ORB_init(['']) - geom = orb.string_to_object(geom_ior) - return geom - if contName == "FactoryServer" and moduleName == "SMESH": - import SMeshHelper - smesh_ior = SMeshHelper.BuildSMESHInstance() - import SMESH - import CORBA - orb=CORBA.ORB_init(['']) - smeshInst = orb.string_to_object(smesh_ior) - return smeshInst - if contName == "FactoryServer" and moduleName == "SHAPERSTUDY": - from SHAPERSTUDY import SHAPERSTUDY_No_Session - from SALOME_ContainerPy import SALOME_ContainerPy_Gen_i - import PortableServer - import KernelServices - obj = orb.resolve_initial_references("RootPOA") - poa = obj._narrow(PortableServer.POA) - pman = poa._get_the_POAManager() - # - cont = SALOME_ContainerPy_Gen_i(orb,poa,"FactoryServer") - conId = poa.activate_object(cont) - conObj = poa.id_to_reference(conId) - # - pman.activate() - # - compoName = "SHAPERSTUDY" - servant = SHAPERSTUDY_No_Session(orb,poa,conObj,"FactoryServer","SHAPERSTUDY_inst_1",compoName) - ret = servant.getCorbaRef() - KernelServices.RegisterCompo(compoName,ret) - return ret - raise RuntimeError("Undealed situation cont = {} module = {}".format(contName,moduleName)) + import importlib + builder_name = moduleName + "_SalomeSessionless" + moduleObj = importlib.import_module(builder_name) + result, orb = moduleObj.buildInstance(orb) + return result + #raise RuntimeError("Undealed situation cont = {} module = {}".format(contName,moduleName)) def salome_init_without_session(): global lcc,myStudy,orb,modulcat -- 2.39.2