Salome HOME
Make the EDF non reg test work in SSL mode : Bug14551_reloadStudy.py
[modules/kernel.git] / src / KERNEL_PY / salome_study.py
index bf6a529869e45f042ee5cf32088b0197416fb30b..c8fab2542b9bcece546963276dd4be76e91c5c91 100644 (file)
@@ -1,5 +1,5 @@
 #  -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
 #
 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -279,6 +279,43 @@ def openStudy(theStudyPath):
 
     #--------------------------------------------------------------------------
 
+def salome_study_init_without_session(theStudyPath=None):
+    """
+    Performs only once study creation or connection.
+    optional argument : theStudyPath
+        None        : attach to the currently active single study;
+                      create new empty study if there is active study
+        <URL> (str) : open study with the given file name
+    """
+    global myStudy, myStudyName
+    global orb, lcc, naming_service, cm
+
+    if verbose(): print("theStudyPath:", theStudyPath)
+    if not myStudy:
+        import CORBA
+        orb = CORBA.ORB_init([''])
+
+        # get Study reference
+        if verbose(): print("looking for study...")
+        import KernelDS
+        myStudy = KernelDS.myStudy()
+        if verbose(): print("Study found")
+        pass
+
+    import types
+    if theStudyPath and isinstance(theStudyPath, (str, bytes)):
+        if isinstance(theStudyPath, bytes):
+            theStudyPath = str(theStudyPath, 'UTF8')
+        openStudy(theStudyPath)
+    else:
+        myStudy.Init()
+
+    myStudyName = myStudy._get_Name()
+
+    return myStudy, myStudyName
+
+    #--------------------------------------------------------------------------
+
 def salome_study_init(theStudyPath=None):
     """
     Performs only once study creation or connection.