6 import glob,os,sys,string,imp
8 from import_hook import register_name
9 from import_hook import register_pattern
12 register_name("libSALOME_LifeCycleCORBA")
13 register_pattern(lambda(x):x.endswith("_idl"))
14 register_pattern(lambda(x):x.endswith("_Swig"))
16 register_name("CORBA")
19 register_name("omniORB")
22 register_name("CosNaming")
25 # Modify omniORB to use right sys.modules dictionnary
26 # with multi-interpreter feature
27 # openModule and newModule are functions of omniORB/__init__.py module
28 # modified to register modules to share
29 # Function to return a Python module for the required IDL module name
30 def openModule(mname, fname=None):
31 # Salome modification start
33 # Salome modification end
36 mod = sys.modules["omniORB.CORBA"]
37 elif sys.modules.has_key(mname):
38 mod = sys.modules[mname]
40 mod = newModule(mname)
42 # Salome modification start
43 import_hook.set_shared_imported(mname,mod)
44 # Salome modification end
47 if not hasattr(mod, "__doc__") or mod.__doc__ is None:
48 mod.__doc__ = "omniORB IDL module " + mname + "\n\n" + \
52 mod.__doc__ = mod.__doc__ + " " + fname + "\n"
56 # Function to create a new module, and any parent modules which do not
59 # Salome modification start
61 # Salome modification end
63 mlist = string.split(mname, ".")
68 current = current + name
70 if sys.modules.has_key(current):
71 mod = sys.modules[current]
73 newmod = imp.new_module(current)
74 if mod: setattr(mod, name, newmod)
75 sys.modules[current] = mod = newmod
77 current = current + "."
80 # Replace openModule and newModule by modified ones
81 # to take into account the sys.modules that matches
82 # the right one (multi-interpreter feature)
83 omniORB.openModule=openModule
84 omniORB.newModule=newModule
87 # Engines, SALOME, SALOMEDS must be imported in that order because :
88 # Engines imports SALOME_Component_idl
89 # SALOME imports SALOME_Session_idl and SALOME_Exception_idl which imports SALOME_Component_idl
90 # and SALOMEDS imports SALOMEDS_idl and SALOMEDS_Attributes_idl which imports SALOME_Exception_idl
91 # If SALOME is imported before Engines, that module would not be completely imported
95 import SALOME_ModuleCatalog
97 def init_shared_modules():
99 This function initializes shared modules that need to be
102 # Problem with omniORB : omniORB creates a C Python module named _omnipy
103 # this module has sub-modules : omni_func, ...
104 # _omnipy is quite a package but import with Python sub-interpreters does not seem to work
105 # To make it work we need to add those sub-modules in sys.modules
108 sys.modules["_omnipy.omni_func"]=_omnipy.omni_func
109 sys.modules["_omnipy.poa_func"]=_omnipy.poa_func
110 sys.modules["_omnipy.poamanager_func"]=_omnipy.poamanager_func
111 sys.modules["_omnipy.orb_func"]=_omnipy.orb_func