6 import glob,os,sys,string,imp
8 from import_hook import register_name
9 from import_hook import register_pattern
12 register_pattern(lambda(x):x.endswith("_idl"))
14 register_name("omniORB")
17 # Modify omniORB to use right sys.modules dictionnary
18 # with multi-interpreter feature
19 # openModule and newModule are functions of omniORB/__init__.py module
20 # modified to register modules to share
21 # Function to return a Python module for the required IDL module name
22 def openModule(mname, fname=None):
23 # Salome modification start
25 # Salome modification end
28 mod = sys.modules["omniORB.CORBA"]
29 elif sys.modules.has_key(mname):
30 mod = sys.modules[mname]
32 mod = newModule(mname)
34 # Salome modification start
35 import_hook.set_shared_imported(mname,mod)
36 # Salome modification end
39 if not hasattr(mod, "__doc__") or mod.__doc__ is None:
40 mod.__doc__ = "omniORB IDL module " + mname + "\n\n" + \
44 mod.__doc__ = mod.__doc__ + " " + fname + "\n"
48 # Function to create a new module, and any parent modules which do not
51 # Salome modification start
53 # Salome modification end
55 mlist = string.split(mname, ".")
60 current = current + name
62 if sys.modules.has_key(current):
63 mod = sys.modules[current]
65 newmod = imp.new_module(current)
66 if mod: setattr(mod, name, newmod)
67 sys.modules[current] = mod = newmod
69 current = current + "."
72 # Replace openModule and newModule by modified ones
73 # to take into account the sys.modules that matches
74 # the right one (multi-interpreter feature)
75 omniORB.openModule=openModule
76 omniORB.newModule=newModule
79 # Engines, SALOME, SALOMEDS must be imported in that order because :
80 # Engines imports SALOME_Component_idl
81 # SALOME imports SALOME_Session_idl and SALOME_Exception_idl which imports SALOME_Component_idl
82 # and SALOMEDS imports SALOMEDS_idl and SALOMEDS_Attributes_idl which imports SALOME_Exception_idl
83 # If SALOME is imported before Engines, that module would not be completely imported
87 import SALOME_ModuleCatalog
89 def init_shared_modules():
91 This function initializes shared modules that need to be
94 # Problem with omniORB : omniORB creates a C Python module named _omnipy
95 # this module has sub-modules : omni_func, ...
96 # _omnipy is quite a package but import with Python sub-interpreters does not seem to work
97 # To make it work we need to add those sub-modules in sys.modules
100 sys.modules["_omnipy.omni_func"]=_omnipy.omni_func
101 sys.modules["_omnipy.poa_func"]=_omnipy.poa_func
102 sys.modules["_omnipy.poamanager_func"]=_omnipy.poamanager_func
103 sys.modules["_omnipy.orb_func"]=_omnipy.orb_func