1 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 This patch of omniORB is made to make it work with multiple interpreters
24 and to correct the problem of incomplete import of CORBA packages
25 in some situations common in SALOME
27 This patch add or modify functions in omniORB module.
29 In multiple interpreters context, omniORB module is meant to be shared among
34 # Map of partially-opened modules
36 # Map of modules to share
39 # Function to return a Python module for the required IDL module name
40 def openModule(mname, fname=None):
41 # Salome modification start
42 # Be sure to use the right module dictionnary
44 # Salome modification end
47 mod = sys.modules["omniORB.CORBA"]
48 # Salome modification start
49 shared_imported[mname]=mod
50 # Salome modification end
52 elif sys.modules.has_key(mname):
53 mod = sys.modules[mname]
55 if _partialModules.has_key(mname):
56 pmod = _partialModules[mname]
57 mod.__dict__.update(pmod.__dict__)
58 del _partialModules[mname]
59 # Salome modification start
60 shared_imported[mname]=mod
61 # Salome modification end
63 elif _partialModules.has_key(mname):
64 mod = _partialModules[mname]
66 # Salome modification start
67 elif shared_imported.get(mname) :
68 mod = shared_imported[mname]
69 # Salome modification end
72 mod = newModule(mname)
75 if not hasattr(mod, "__doc__") or mod.__doc__ is None:
76 mod.__doc__ = "omniORB IDL module " + mname + "\n\n" + \
80 mod.__doc__ = mod.__doc__ + " " + fname + "\n"
84 # Function to create a new module, and any parent modules which do not
87 # Salome modification start
88 # Be sure to use the right module dictionnary
90 # Salome modification end
92 mlist = string.split(mname, ".")
97 current = current + name
99 if sys.modules.has_key(current):
100 mod = sys.modules[current]
102 elif _partialModules.has_key(current):
103 mod = _partialModules[current]
106 newmod = imp.new_module(current)
107 if mod: setattr(mod, name, newmod)
108 _partialModules[current] = mod = newmod
110 current = current + "."
114 # Function to update a module with the partial module store in the
116 def updateModule(mname):
117 # Salome modification start
118 # Be sure to use the right module dictionnary
120 # Salome modification end
121 if _partialModules.has_key(mname):
122 pmod = _partialModules[mname]
123 mod = sys.modules[mname]
124 mod.__dict__.update(pmod.__dict__)
125 del _partialModules[mname]
127 # Salome modification start
128 shared_imported[mname]=sys.modules[mname]
129 # Salome modification end
131 omniORB.updateModule=updateModule
132 omniORB.newModule=newModule
133 omniORB.openModule=openModule