Salome HOME
Merged from BR_V51_RB (removed Batch and added libBatch as an optional prerequisite).
[modules/kernel.git] / src / KERNEL_PY / kernel_shared_modules.py
index 5be2f15f469c0c9337fdf85d090523638279a2f9..74ddf9587fb987c6349f7c3f1abf3868b525c0d6 100755 (executable)
@@ -1,3 +1,24 @@
+#  Copyright (C) 2007-2008  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
+#
+#  This library is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU Lesser General Public
+#  License as published by the Free Software Foundation; either
+#  version 2.1 of the License.
+#
+#  This library is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  Lesser General Public License for more details.
+#
+#  You should have received a copy of the GNU Lesser General Public
+#  License along with this library; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+#  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
 """
 
 """
@@ -13,100 +34,19 @@ register_name("libSALOME_LifeCycleCORBA")
 register_pattern(lambda(x):x.endswith("_idl"))
 register_pattern(lambda(x):x.endswith("_Swig"))
 
+register_name("omniORB")
 register_name("CORBA")
-import CORBA
+register_name("CosNaming")
+register_name("CosNaming__POA")
+register_name("omnipatch")
 
-register_name("omniORB")
 import omniORB
-
-register_name("CosNaming")
+from omniORB import CORBA
 import CosNaming
-
-# Modify omniORB to use right sys.modules dictionnary 
-# with multi-interpreter feature
-# openModule and newModule are functions of omniORB/__init__.py module
-# modified to register modules to share
-# Function to return a Python module for the required IDL module name
-def openModule(mname, fname=None):
-    # Salome modification start
-    import sys
-    # Salome modification end
-
-    if mname == "CORBA":
-        mod = sys.modules["omniORB.CORBA"]
-    elif sys.modules.has_key(mname):
-        mod = sys.modules[mname]
-    else:
-        mod = newModule(mname)
-
-    # Salome modification start
-    import_hook.set_shared_imported(mname,mod)
-    # Salome modification end
-
-
-    if not hasattr(mod, "__doc__") or mod.__doc__ is None:
-        mod.__doc__ = "omniORB IDL module " + mname + "\n\n" + \
-                      "Generated from:\n\n"
-
-    if fname is not None:
-        mod.__doc__ = mod.__doc__ + "  " + fname + "\n"
-
-    return mod
-
-# Function to create a new module, and any parent modules which do not
-# already exist
-def newModule(mname):
-    # Salome modification start
-    import sys
-    # Salome modification end
-
-    mlist   = string.split(mname, ".")
-    current = ""
-    mod     = None
-
-    for name in mlist:
-        current = current + name
-
-        if sys.modules.has_key(current):
-            mod = sys.modules[current]
-        else:
-            newmod = imp.new_module(current)
-            if mod: setattr(mod, name, newmod)
-            sys.modules[current] = mod = newmod
-
-        current = current + "."
-
-    return mod
-# Replace openModule and newModule by modified ones
-# to take into account the sys.modules that matches
-# the right one (multi-interpreter feature)
-omniORB.openModule=openModule
-omniORB.newModule=newModule
-
-# BE CAREFUL
-# Engines, SALOME, SALOMEDS must be imported in that order because :
-# Engines imports SALOME_Component_idl
-# SALOME imports SALOME_Session_idl and SALOME_Exception_idl which imports SALOME_Component_idl
-# and SALOMEDS imports SALOMEDS_idl and SALOMEDS_Attributes_idl which imports SALOME_Exception_idl
-# If SALOME is imported before Engines, that module would not be completely imported
-import Engines
-import SALOME
-import SALOMEDS
-import SALOME_ModuleCatalog
+import CosNaming__POA
+import omnipatch
 
 def init_shared_modules():
    """
       This function initializes shared modules that need to be
    """
-   # EDF-CCAR:
-   # Problem with omniORB : omniORB creates a C Python module named  _omnipy
-   # this module has sub-modules : omni_func, ...
-   # _omnipy is quite a package but import with Python sub-interpreters does not seem to work
-   # To make it work we need to add those sub-modules in sys.modules
-   import sys
-   import _omnipy
-   sys.modules["_omnipy.omni_func"]=_omnipy.omni_func
-   sys.modules["_omnipy.poa_func"]=_omnipy.poa_func
-   sys.modules["_omnipy.poamanager_func"]=_omnipy.poamanager_func
-   sys.modules["_omnipy.orb_func"]=_omnipy.orb_func
-