GSI Object Oriented Online Offline (Go4)
GO4-6.4.0
Loading...
Searching...
No Matches
python
go4py
internals
facade.py
Go to the documentation of this file.
1
2
import
sys
3
4
5
class
Facade
(object):
6
7
def
__init__
(self, modulename):
8
"""
9
Replaces a module with an instance of a types.ModuleType-based class
10
modulename is probably given by __name__ in that module
11
12
Example:
13
@Facade(__name__)
14
class AnInteriorClass(ModuleType):
15
pass
16
"""
17
self.
modulename
= modulename
18
19
def
__call__
(self, Interior):
20
"""
21
Replace current module with an instance of Interior in sys.modules
22
Update the globals of this instance from the globals of the module
23
Keep a reference to the overwritten "scaffold" module to avoid GC
24
cf. https://mail.python.org/pipermail/python-ideas/2012-May/014969.html
25
"""
26
n = self.
modulename
27
w = Interior(n)
28
w.__dict__.update(sys.modules[n].__dict__)
29
w._scaffold = sys.modules[n]
30
sys.modules[n] = w
31
32
33
go4py.internals.facade.Facade
Definition
facade.py:5
go4py.internals.facade.Facade.__call__
__call__(self, Interior)
Definition
facade.py:19
go4py.internals.facade.Facade.__init__
__init__(self, modulename)
Definition
facade.py:7
go4py.internals.facade.Facade.modulename
modulename
Definition
facade.py:17
Generated by
1.13.2