Salome HOME
Corrections for SSL mode
authorViktor UZLOV <vuzlov@centos7-01.nnov.opencascade.com>
Wed, 10 Nov 2021 16:13:53 +0000 (19:13 +0300)
committervsr <vsr@opencascade.com>
Thu, 11 Nov 2021 09:39:10 +0000 (12:39 +0300)
src/PYHELLO/PYHELLO.py
src/PYHELLO/PYHELLO_SalomeSessionless.py
src/PYHELLO/PYHELLO_utils.py

index 77ed258a712fdf4634e9c684955b6c7806feab7b..29cca24bf70dd88ee73ba1b2e67770c617fe73d5 100644 (file)
@@ -54,12 +54,8 @@ class PYHELLO(PYHELLO_ORB__POA.PYHELLO_Gen,
             self._naming_service = SALOME_ComponentPy.SALOME_NamingServicePy_i( self._orb )
         else:
             self._naming_service = SALOME_Embedded_NamingService_ClientPy.SALOME_Embedded_NamingService_ClientPy(emb_ns)
-        #
         pass
 
-    def getNamingService(self):
-        return self._naming_service
-
     """
     Get version information.
     """
@@ -86,7 +82,7 @@ class PYHELLO(PYHELLO_ORB__POA.PYHELLO_Gen,
     Create object.
     """
     def createObject( self, name ):
-        study = getStudy( self._naming_service )
+        study = getStudy()
         builder = study.NewBuilder()
         father  = findOrCreateComponent()
         obj  = builder.NewObject( father )
index 6d8da44b47987912e1808f6cc23007bdefd2aedc..2c911f22bc3b1f78cff8c7aa8371d74a2479e358 100644 (file)
 #
 
 def buildInstance(orb):
+    from PYHELLO import PYHELLO
+
+    # set SSL mode, if not done yes
     import KernelBasis
     KernelBasis.setSSLMode(True)
-    from PYHELLO import PYHELLO
-    from SALOME_ContainerPy import SALOME_ContainerPy_SSL_i
-    import PortableServer
+
+    # check if PYHELLO is already registered
     import KernelServices
+    try:
+        return pyhello, orb
+    except Exception:
+        pass
+
+    # initialize and register PYHELLO engine
+    import PortableServer
     obj = orb.resolve_initial_references("RootPOA")
     poa = obj._narrow(PortableServer.POA)
     pman = poa._get_the_POAManager()
-    #
-    cont = SALOME_ContainerPy_SSL_i(orb,poa,"FactoryServer")
-    conId = poa.activate_object(cont)
-    conObj = poa.id_to_reference(conId)
-    #
     pman.activate()
     #
-    compoName = "PYHELLO"
-    servant = PYHELLO(orb,poa,conObj,"FactoryServer","PYHELLO_inst_1",compoName)
+    from SALOME_ContainerPy import SALOME_ContainerPy_SSL_i
+    cont = SALOME_ContainerPy_SSL_i(orb, poa, "FactoryServer")
+    conObj = poa.id_to_reference(poa.activate_object(cont))
+    #
+    servant = PYHELLO(orb, poa, conObj, "FactoryServer", "PYHELLO_inst_1", "PYHELLO")
     ret = servant.getCorbaRef()
-    KernelServices.RegisterCompo(compoName,ret)
+    KernelServices.RegisterCompo("PYHELLO", ret)
     return ret, orb
index 6766427dea0ccebe53acf6c48e5299ae3338d4eb..94d47d2656a6d6f7ff1f398abbbb2a95d5ad60df 100644 (file)
@@ -42,6 +42,7 @@ __all__ = [
 from omniORB import CORBA
 from SALOME_NamingServicePy import SALOME_NamingServicePy_i
 from LifeCycleCORBA import LifeCycleCORBA
+import salome
 import SALOMEDS
 import SALOMEDS_Attributes_idl
 import PYHELLO_ORB
@@ -98,36 +99,23 @@ def verbose():
 ###
 # Get ORB reference
 ###
-__orb__ = None
 def getORB():
-    global __orb__
-    if __orb__ is None:
-        __orb__ = CORBA.ORB_init( [''], CORBA.ORB_ID )
-        pass
-    return __orb__
+    salome.salome_init()
+    return salome.orb
 
 ##
 # Get life cycle CORBA instance
 ##
-__lcc__ = None
 def getLCC():
-    global __lcc__
-    if __lcc__ is None:
-        __lcc__ = LifeCycleCORBA( getORB() )
-        pass
-    return __lcc__
+    salome.salome_init()
+    return salome.lcc
 
 ##
 # Get study
 ###
-__study__ = None
 def getStudy():
-    global __study__
-    if __study__ is None:
-        obj = __engine__.getNamingService().Resolve( '/Study' )
-        __study__ = obj._narrow( SALOMEDS.Study )
-        pass
-    return __study__
+    salome.salome_init()
+    return salome.myStudy
 
 ###
 # Get PYHELLO engine
@@ -136,19 +124,7 @@ __engine__ = None
 def getEngine():
     global __engine__
     if __engine__ is None:
-        import KernelBasis
-        if KernelBasis.getSSLMode():
-            import salome
-            import PYHELLO
-            from SALOME_ContainerPy import SALOME_ContainerPy_SSL_i
-            poa = salome.orb.resolve_initial_references("RootPOA")
-            poaManager = poa._get_the_POAManager()
-            poaManager.activate()
-            cpy_i = SALOME_ContainerPy_SSL_i(salome.orb, poa, "FactoryServerPy")
-            cpy_ref = cpy_i._this()
-            __engine__ = PYHELLO.PYHELLO(salome.orb,poa,cpy_ref,"FactoryServerPy", "PYHELLO_inst_2" , moduleName())
-        else:
-            __engine__ = getLCC().FindOrLoadComponent( "FactoryServerPy", moduleName() )
+        __engine__ = getLCC().FindOrLoadComponent( "FactoryServerPy", moduleName() )
         pass
     return __engine__