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]
64 mod = newModule(mname)
67 if not hasattr(mod, "__doc__") or mod.__doc__ is None:
68 mod.__doc__ = "omniORB IDL module " + mname + "\n\n" + \
72 mod.__doc__ = mod.__doc__ + " " + fname + "\n"
76 # Function to create a new module, and any parent modules which do not
79 # Salome modification start
80 # Be sure to use the right module dictionnary
82 # Salome modification end
84 mlist = string.split(mname, ".")
89 current = current + name
91 if sys.modules.has_key(current):
92 mod = sys.modules[current]
94 elif _partialModules.has_key(current):
95 mod = _partialModules[current]
98 newmod = imp.new_module(current)
99 if mod: setattr(mod, name, newmod)
100 _partialModules[current] = mod = newmod
102 current = current + "."
106 # Function to update a module with the partial module store in the
108 def updateModule(mname):
109 # Salome modification start
110 # Be sure to use the right module dictionnary
112 # Salome modification end
113 if _partialModules.has_key(mname):
114 pmod = _partialModules[mname]
115 mod = sys.modules[mname]
116 mod.__dict__.update(pmod.__dict__)
117 del _partialModules[mname]
119 # Salome modification start
120 shared_imported[mname]=sys.modules[mname]
121 # Salome modification end
123 omniORB.updateModule=updateModule
124 omniORB.newModule=newModule
125 omniORB.openModule=openModule