register_name("omniORB")
import omniORB
-register_name("CosNaming")
-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
+register_name("omnipatch")
+import omnipatch
# BE CAREFUL
# Engines, SALOME, SALOMEDS must be imported in that order because :
--- /dev/null
+"""
+ This patch of omniORB is made to make it work with multiple interpreters
+ and to correct the problem of incomplete import of CORBA packages
+ in some situations common in SALOME
+
+ This patch add or modify functions in omniORB module.
+
+ In multiple interpreters context, omniORB module is meant to be shared among
+ all interpreters
+"""
+import sys,string,imp
+import omniORB
+# Map of partially-opened modules
+_partialModules = {}
+# Map of modules to share
+shared_imported={}
+
+# Function to return a Python module for the required IDL module name
+def openModule(mname, fname=None):
+ # Salome modification start
+ # Be sure to use the right module dictionnary
+ import sys
+ # Salome modification end
+
+ if mname == "CORBA":
+ mod = sys.modules["omniORB.CORBA"]
+
+ elif sys.modules.has_key(mname):
+ mod = sys.modules[mname]
+
+ if _partialModules.has_key(mname):
+ pmod = _partialModules[mname]
+ mod.__dict__.update(pmod.__dict__)
+ del _partialModules[mname]
+
+ elif _partialModules.has_key(mname):
+ mod = _partialModules[mname]
+
+ else:
+ mod = newModule(mname)
+
+ # Salome modification start
+ 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
+ # Be sure to use the right module dictionnary
+ 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]
+
+ elif _partialModules.has_key(current):
+ mod = _partialModules[current]
+
+ else:
+ newmod = imp.new_module(current)
+ if mod: setattr(mod, name, newmod)
+ _partialModules[current] = mod = newmod
+
+ current = current + "."
+
+ return mod
+
+# Function to update a module with the partial module store in the
+# partial module map
+def updateModule(mname):
+ if _partialModules.has_key(mname):
+ pmod = _partialModules[mname]
+ mod = sys.modules[mname]
+ mod.__dict__.update(pmod.__dict__)
+ del _partialModules[mname]
+
+omniORB.updateModule=updateModule
+omniORB.newModule=newModule
+omniORB.openModule=openModule
+