1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2024 CEA, EDF, 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, or (at your option) any later version.
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
25 This patch of omniORB is made to make it work with multiple interpreters
26 and to correct the problem of incomplete import of CORBA packages
27 in some situations common in SALOME
29 This patch add or modify functions in omniORB module.
31 In multiple interpreters context, omniORB module is meant to be shared among
36 # Map of partially-opened modules
38 # Map of modules to share
41 # Function to return a Python module for the required IDL module name
42 def openModule(mname, fname=None):
43 # Salome modification start
44 # Be sure to use the right module dictionary
46 # Salome modification end
49 mod = sys.modules["omniORB.CORBA"]
50 # Salome modification start
51 shared_imported[mname]=mod
52 # Salome modification end
54 elif mname in sys.modules:
55 mod = sys.modules[mname]
57 if mname in _partialModules:
58 pmod = _partialModules[mname]
59 mod.__dict__.update(pmod.__dict__)
60 del _partialModules[mname]
61 # Salome modification start
62 shared_imported[mname]=mod
63 # Salome modification end
65 elif mname in _partialModules:
66 mod = _partialModules[mname]
68 # Salome modification start
69 elif shared_imported.get(mname) :
70 mod = shared_imported[mname]
71 # Salome modification end
74 mod = newModule(mname)
77 if not hasattr(mod, "__doc__") or mod.__doc__ is None:
78 mod.__doc__ = "omniORB IDL module " + mname + "\n\n" + \
82 mod.__doc__ = mod.__doc__ + " " + fname + "\n"
86 # Function to create a new module, and any parent modules which do not
89 # Salome modification start
90 # Be sure to use the right module dictionary
92 # Salome modification end
94 mlist = string.split(mname, ".")
99 current = current + name
101 if current in sys.modules:
102 mod = sys.modules[current]
104 elif current in _partialModules:
105 mod = _partialModules[current]
108 newmod = imp.new_module(current)
109 if mod: setattr(mod, name, newmod)
110 _partialModules[current] = mod = newmod
112 current = current + "."
116 # Function to update a module with the partial module store in the
118 def updateModule(mname):
119 # Salome modification start
120 # Be sure to use the right module dictionary
122 # Salome modification end
123 if mname in _partialModules:
124 pmod = _partialModules[mname]
125 mod = sys.modules[mname]
126 mod.__dict__.update(pmod.__dict__)
127 del _partialModules[mname]
129 # Salome modification start
130 shared_imported[mname]=sys.modules[mname]
131 # Salome modification end
133 omniORB.updateModule=updateModule
134 omniORB.newModule=newModule
135 omniORB.openModule=openModule