Lightweight Framework - Remove circular dependencies in an event-driven way by decoupling your imports from your class/function execution.
Project description
EZ Module Manager
A plug-n-play, modular Service Locator
Get it
#PyPI
pip install ezmodulemanager
Read the full documentation(or Quick Start) on GitHub
Why this 'Service Locator'?
This 'Service Locator' is a structural design pattern designed to decouple object registration from execution. It was popularized by Martin Fowler, a pioneer of software architecture and a co-author of the Agile Manifesto.
How it works: 'Discovery'
This module uses an event-driven startup sequence. By gating the entry point with if __name__ == '__main__':, the system triggers a dynamic import event using importlib.
- Registration: Class, clas methods, and functions use the
@mmregdecorator to register themselves automatically during the import phase. - Resolution: Your logic then uses
get_ob()to 'grab and go', retrieving the objects it needs without hard-coded import dependencies.
The 'Black Box' & Future Type Safety
Regarding type hints, I recognize that using a locator can
create a 'black box'(passing/returning Any). I architected this
framework solely for a project that required high flexibility
where type checking does not matter.
- Current State: It is a lightweight, high-speed discovery engine.
- Future Roadmap: I am working on a TypeVar type-checking module that will allow you to implement custom type checks on retrieved objects, turning the "black box" into a transparent, type-safe registry.
I’m not trying to replace Dependency Injection. I’m offering a reimagined, Pythonic alternative for developers who value simplicity without the bloat of Enterprise frameworks. Check out the source on GitHub to see just how minimal the implementation is.
Features
Supports All Object Types: Functions, Classes, Class methods, Variables.
Decoupled Object Execution: Call a function in module_A from
module_B without the modules
ever importing one another.
Isolated Registry: A powerful registry component that stores the reference of any 'registered' objects, allowing for communication across your entire codebase.
Circular Dependency Elimination: Bypasses the common pitfalls of Python imports by utilizing a centralized registry for object access.
Sequential Event-Driven Loading: Uses importlib to load
modules via custom import_modlist(), ensuring every object is
registered before your application logic ever executes it.
Versatile Calling Methods:
-
Direct Calls: Execute functions/class methods immediately across namespaces (with or without arguments).
-
Deferred Use: Retrieve and store classes, methods, and functions for later use.
Zero-Bloat System: No third-party dependencies; the system is designed to be lightweight and stay out of your way.
Framework Agnostic: Compatible with any standard Python entry point, including Django, Flask, and FastAPI. Completely standalone and modular.
Version: python 3.8+
License
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ezmodulemanager-1.0.1.tar.gz.
File metadata
- Download URL: ezmodulemanager-1.0.1.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
edfc0257a5e5f9738dbbd48d5efe0f7312b603c675970a235b0dcb2da4ca641d
|
|
| MD5 |
3824f323964fb0509609849b9b7aa776
|
|
| BLAKE2b-256 |
cc9d12c5bcf9ddcc8bc05bea70bdfa0c72bee49c57f4054cd678cd04cae0d6a2
|
File details
Details for the file ezmodulemanager-1.0.1-py3-none-any.whl.
File metadata
- Download URL: ezmodulemanager-1.0.1-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1dacb1eb7d99a27308b8b35809684312ca8096f984d6e8db1231b60fe95e4038
|
|
| MD5 |
b9ef003f8e87057ead46094c3f6d850d
|
|
| BLAKE2b-256 |
7f85d67508c0b64d64f4b26bb96c4f98d8c177b69f7a27e4e82ddc9ff710c9db
|