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"))
13 register_pattern(lambda(x):x.endswith("_Swig"))
15 register_name("omniORB")
18 register_name("CosNaming")
21 # Modify omniORB to use right sys.modules dictionnary
22 # with multi-interpreter feature
23 # openModule and newModule are functions of omniORB/__init__.py module
24 # modified to register modules to share
25 # Function to return a Python module for the required IDL module name
26 def openModule(mname, fname=None):
27 # Salome modification start
29 # Salome modification end
32 mod = sys.modules["omniORB.CORBA"]
33 elif sys.modules.has_key(mname):
34 mod = sys.modules[mname]
36 mod = newModule(mname)
38 # Salome modification start
39 import_hook.set_shared_imported(mname,mod)
40 # Salome modification end
43 if not hasattr(mod, "__doc__") or mod.__doc__ is None:
44 mod.__doc__ = "omniORB IDL module " + mname + "\n\n" + \
48 mod.__doc__ = mod.__doc__ + " " + fname + "\n"
52 # Function to create a new module, and any parent modules which do not
55 # Salome modification start
57 # Salome modification end
59 mlist = string.split(mname, ".")
64 current = current + name
66 if sys.modules.has_key(current):
67 mod = sys.modules[current]
69 newmod = imp.new_module(current)
70 if mod: setattr(mod, name, newmod)
71 sys.modules[current] = mod = newmod
73 current = current + "."
76 # Replace openModule and newModule by modified ones
77 # to take into account the sys.modules that matches
78 # the right one (multi-interpreter feature)
79 omniORB.openModule=openModule
80 omniORB.newModule=newModule
83 # Engines, SALOME, SALOMEDS must be imported in that order because :
84 # Engines imports SALOME_Component_idl
85 # SALOME imports SALOME_Session_idl and SALOME_Exception_idl which imports SALOME_Component_idl
86 # and SALOMEDS imports SALOMEDS_idl and SALOMEDS_Attributes_idl which imports SALOME_Exception_idl
87 # If SALOME is imported before Engines, that module would not be completely imported
91 import SALOME_ModuleCatalog
93 def init_shared_modules():
95 This function initializes shared modules that need to be
98 # Problem with omniORB : omniORB creates a C Python module named _omnipy
99 # this module has sub-modules : omni_func, ...
100 # _omnipy is quite a package but import with Python sub-interpreters does not seem to work
101 # To make it work we need to add those sub-modules in sys.modules
104 sys.modules["_omnipy.omni_func"]=_omnipy.omni_func
105 sys.modules["_omnipy.poa_func"]=_omnipy.poa_func
106 sys.modules["_omnipy.poamanager_func"]=_omnipy.poamanager_func
107 sys.modules["_omnipy.orb_func"]=_omnipy.orb_func