Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

overlaymodule-0.0.1.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

overlaymodule-0.0.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file overlaymodule-0.0.1.tar.gz.

File metadata

  • Download URL: overlaymodule-0.0.1.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for overlaymodule-0.0.1.tar.gz
Algorithm Hash digest
SHA256 777ecac76c11160cbaaf7ec4ad93c7b634f98745c86f6302c221f5bf940ea0a4
MD5 513f454331bc5dbee60123100599175e
BLAKE2b-256 03fbd7cf69eea86b10f3387e7ac8b263870e7a16fb4f77d71dc97545f5c5ca13

See more details on using hashes here.

File details

Details for the file overlaymodule-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for overlaymodule-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d1a59894774ab1f0448af533ac58b5aad9e811a0204486ec3c0f05af3736b2bf
MD5 11a8fe3f1e57d260aa0ca1e2a8241ec5
BLAKE2b-256 4567b63d35a304a419337ccbc499a18281990e4af45ca94d01c83c52592cb9aa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page