A Special Module Loader that can load modules with overlays.
Project description
OverlayModule
This module finder makes it possible to load modules with overlays. This can be useful in cases you try to customize some kind of application in places at moment that is out of your control.
For example, it is useful when you want to customize an application that make extensive uses of global. This module will allow you to load an overlay over a module that is being loaded right after the module has been loaded.
Let say you have this module a.b
. You'd want to customize the class a.b:Application
.
To make sure that something that inherits later from a.b:Application
will in fact
inherit from o.overlay.a.b:Application
.
When the module is being loaded it will first load a.b
then it will execute the module
o.overlay.a.b
on top of the module a.b
.
In short, this is more or less monkey patching on steroid.
How to use:
For the script using it:
import importlib
from overlaymodule import OverlayFinder
module_spec = importlib.util.find_spec('a')
module_path = odoo_spec.submodule_search_locations[0]
sys.meta_path.insert(
0,
OverlayFinder(
'a',
module_path,
overlays=[
"o.overlay",
]
)
)
from a.b import Application, OldApplication
A module overlay o.overlay.a.b
# since a.b is already loaded, it's possible to import it within itself!
from a.b import Application as OldApplication
class Application(OldApplication):
pass
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file overlaymodule-0.0.3.tar.gz
.
File metadata
- Download URL: overlaymodule-0.0.3.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72ab853ca532ff0864cdf6d8d745d6bc39cc2bfc452ca8008074fa8d2dab0cd6 |
|
MD5 | 4422cff1cbf6a95684fa986a3dca6179 |
|
BLAKE2b-256 | 0cfedcc6ae5fa0dce87532e26b2dcb648dd2938eb128222372cddb294ce7172f |
File details
Details for the file overlaymodule-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: overlaymodule-0.0.3-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f999cf8f151e30380643d7da381f2dcfe1eb648928d6db21b10c5a32634263f1 |
|
MD5 | 53ba0eec085aa2b6127af425194c6ea2 |
|
BLAKE2b-256 | d0f122aa16cb21ee2ef4ec32419f7ed6eb13e07df190402377dc58bed2b81526 |