1 # Copyright (C) 2005 OPEN CASCADE, CEA, EDF R&D, LEG
2 # PRINCIPIA R&D, EADS CCR, Lip6, BV, CEDRAT
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
8 # This library is distributed in the hope that it will be useful
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 This patch of omniORB is made to make it work with multiple interpreters
21 and to correct the problem of incomplete import of CORBA packages
22 in some situations common in SALOME
24 This patch add or modify functions in omniORB module.
26 In multiple interpreters context, omniORB module is meant to be shared among
31 # Map of partially-opened modules
33 # Map of modules to share
36 # Function to return a Python module for the required IDL module name
37 def openModule(mname, fname=None):
38 # Salome modification start
39 # Be sure to use the right module dictionnary
41 # Salome modification end
44 mod = sys.modules["omniORB.CORBA"]
45 # Salome modification start
46 shared_imported[mname]=mod
47 # Salome modification end
49 elif sys.modules.has_key(mname):
50 mod = sys.modules[mname]
52 if _partialModules.has_key(mname):
53 pmod = _partialModules[mname]
54 mod.__dict__.update(pmod.__dict__)
55 del _partialModules[mname]
56 # Salome modification start
57 shared_imported[mname]=mod
58 # Salome modification end
60 elif _partialModules.has_key(mname):
61 mod = _partialModules[mname]
63 # Salome modification start
64 elif shared_imported.get(mname) :
65 mod = shared_imported[mname]
66 # Salome modification end
69 mod = newModule(mname)
72 if not hasattr(mod, "__doc__") or mod.__doc__ is None:
73 mod.__doc__ = "omniORB IDL module " + mname + "\n\n" + \
77 mod.__doc__ = mod.__doc__ + " " + fname + "\n"
81 # Function to create a new module, and any parent modules which do not
84 # Salome modification start
85 # Be sure to use the right module dictionnary
87 # Salome modification end
89 mlist = string.split(mname, ".")
94 current = current + name
96 if sys.modules.has_key(current):
97 mod = sys.modules[current]
99 elif _partialModules.has_key(current):
100 mod = _partialModules[current]
103 newmod = imp.new_module(current)
104 if mod: setattr(mod, name, newmod)
105 _partialModules[current] = mod = newmod
107 current = current + "."
111 # Function to update a module with the partial module store in the
113 def updateModule(mname):
114 # Salome modification start
115 # Be sure to use the right module dictionnary
117 # Salome modification end
118 if _partialModules.has_key(mname):
119 pmod = _partialModules[mname]
120 mod = sys.modules[mname]
121 mod.__dict__.update(pmod.__dict__)
122 del _partialModules[mname]
124 # Salome modification start
125 shared_imported[mname]=sys.modules[mname]
126 # Salome modification end
128 omniORB.updateModule=updateModule
129 omniORB.newModule=newModule
130 omniORB.openModule=openModule