1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 This patch of omniORB is made to make it work with multiple interpreters
25 and to correct the problem of incomplete import of CORBA packages
26 in some situations common in SALOME
28 This patch add or modify functions in omniORB module.
30 In multiple interpreters context, omniORB module is meant to be shared among
35 # Map of partially-opened modules
37 # Map of modules to share
40 # Function to return a Python module for the required IDL module name
41 def openModule(mname, fname=None):
42 # Salome modification start
43 # Be sure to use the right module dictionnary
45 # Salome modification end
48 mod = sys.modules["omniORB.CORBA"]
49 # Salome modification start
50 shared_imported[mname]=mod
51 # Salome modification end
53 elif sys.modules.has_key(mname):
54 mod = sys.modules[mname]
56 if _partialModules.has_key(mname):
57 pmod = _partialModules[mname]
58 mod.__dict__.update(pmod.__dict__)
59 del _partialModules[mname]
60 # Salome modification start
61 shared_imported[mname]=mod
62 # Salome modification end
64 elif _partialModules.has_key(mname):
65 mod = _partialModules[mname]
67 # Salome modification start
68 elif shared_imported.get(mname) :
69 mod = shared_imported[mname]
70 # Salome modification end
73 mod = newModule(mname)
76 if not hasattr(mod, "__doc__") or mod.__doc__ is None:
77 mod.__doc__ = "omniORB IDL module " + mname + "\n\n" + \
81 mod.__doc__ = mod.__doc__ + " " + fname + "\n"
85 # Function to create a new module, and any parent modules which do not
88 # Salome modification start
89 # Be sure to use the right module dictionnary
91 # Salome modification end
93 mlist = string.split(mname, ".")
98 current = current + name
100 if sys.modules.has_key(current):
101 mod = sys.modules[current]
103 elif _partialModules.has_key(current):
104 mod = _partialModules[current]
107 newmod = imp.new_module(current)
108 if mod: setattr(mod, name, newmod)
109 _partialModules[current] = mod = newmod
111 current = current + "."
115 # Function to update a module with the partial module store in the
117 def updateModule(mname):
118 # Salome modification start
119 # Be sure to use the right module dictionnary
121 # Salome modification end
122 if _partialModules.has_key(mname):
123 pmod = _partialModules[mname]
124 mod = sys.modules[mname]
125 mod.__dict__.update(pmod.__dict__)
126 del _partialModules[mname]
128 # Salome modification start
129 shared_imported[mname]=sys.modules[mname]
130 # Salome modification end
132 omniORB.updateModule=updateModule
133 omniORB.newModule=newModule
134 omniORB.openModule=openModule