muffin 0.100.0__py3-none-any.whl → 0.101.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- muffin/plugins.py +16 -4
- {muffin-0.100.0.dist-info → muffin-0.101.0.dist-info}/METADATA +2 -1
- {muffin-0.100.0.dist-info → muffin-0.101.0.dist-info}/RECORD +5 -5
- {muffin-0.100.0.dist-info → muffin-0.101.0.dist-info}/WHEEL +1 -1
- {muffin-0.100.0.dist-info → muffin-0.101.0.dist-info}/entry_points.txt +0 -0
muffin/plugins.py
CHANGED
@@ -30,7 +30,7 @@ class BasePlugin(ABC):
|
|
30
30
|
name: str
|
31
31
|
|
32
32
|
# Plugin options with default values
|
33
|
-
defaults: ClassVar[Mapping[str, Any]] = {}
|
33
|
+
defaults: ClassVar[Mapping[str, Any]] = {"disabled": False}
|
34
34
|
|
35
35
|
# Optional middleware method
|
36
36
|
middleware: Optional[Callable] = None
|
@@ -50,7 +50,9 @@ class BasePlugin(ABC):
|
|
50
50
|
msg = "Plugin.name is required"
|
51
51
|
raise TypeError(msg)
|
52
52
|
|
53
|
-
self.cfg = Config(
|
53
|
+
self.cfg = Config(
|
54
|
+
config_config={"update_from_env": False}, **dict({"disabled": False}, **self.defaults)
|
55
|
+
)
|
54
56
|
self.__app__ = app
|
55
57
|
|
56
58
|
if app is not None:
|
@@ -62,6 +64,14 @@ class BasePlugin(ABC):
|
|
62
64
|
"""Human readable representation."""
|
63
65
|
return f"<muffin.Plugin: { self.name }>"
|
64
66
|
|
67
|
+
async def __aenter__(self):
|
68
|
+
if self.startup is not None:
|
69
|
+
await self.startup()
|
70
|
+
|
71
|
+
async def __aexit__(self, exc_type, exc, tb):
|
72
|
+
if self.shutdown is not None:
|
73
|
+
await self.shutdown()
|
74
|
+
|
65
75
|
@property
|
66
76
|
def app(self) -> Application:
|
67
77
|
"""Get the application."""
|
@@ -70,7 +80,7 @@ class BasePlugin(ABC):
|
|
70
80
|
|
71
81
|
return self.__app__
|
72
82
|
|
73
|
-
def setup(self, app: Application, *, name: Optional[str] = None, **options):
|
83
|
+
def setup(self, app: Application, *, name: Optional[str] = None, **options) -> bool:
|
74
84
|
"""Bind app and update the plugin's configuration."""
|
75
85
|
# allow to redefine the name for multi plugins with same type
|
76
86
|
self.name = name or self.name
|
@@ -84,7 +94,7 @@ class BasePlugin(ABC):
|
|
84
94
|
self.cfg.update_from_dict(options)
|
85
95
|
if self.cfg.disabled:
|
86
96
|
app.logger.warning("Plugin %s is disabled", self.name)
|
87
|
-
return
|
97
|
+
return False
|
88
98
|
|
89
99
|
app.plugins[self.name] = self
|
90
100
|
self.__app__ = app
|
@@ -100,3 +110,5 @@ class BasePlugin(ABC):
|
|
100
110
|
# Bind shutdown
|
101
111
|
if self.shutdown:
|
102
112
|
app.on_shutdown(self.shutdown)
|
113
|
+
|
114
|
+
return True
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: muffin
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.101.0
|
4
4
|
Summary: Muffin is a fast, simple and asyncronous web-framework for Python 3 (asyncio, trio, curio)
|
5
5
|
Home-page: https://github.com/klen/muffin
|
6
6
|
License: MIT
|
@@ -19,6 +19,7 @@ Classifier: Programming Language :: Python :: 3.8
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.9
|
20
20
|
Classifier: Programming Language :: Python :: 3.10
|
21
21
|
Classifier: Programming Language :: Python :: 3.11
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
22
23
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
23
24
|
Classifier: Topic :: Internet :: WWW/HTTP
|
24
25
|
Provides-Extra: standard
|
@@ -4,12 +4,12 @@ muffin/constants.py,sha256=Ga1UJiEdXUk6dIEH_IEVYkFSZxQFPhxie7fCJwQY8V0,71
|
|
4
4
|
muffin/errors.py,sha256=I-vKbMMBiMU07zPdKvoJKqA7s4xYAUA-4oZXrRMRzcM,701
|
5
5
|
muffin/handler.py,sha256=cbEt5hKSGBTHSI5IEZ9T8RNiKcvcliYVsY_1PPnvpZE,3755
|
6
6
|
muffin/manage.py,sha256=yOKhfF_wEfHCsSrQNzt6wDiPcMQlVhzCK1XLy5i5ve8,8842
|
7
|
-
muffin/plugins.py,sha256=
|
7
|
+
muffin/plugins.py,sha256=V2tyKR371mxYsCdAq7MIxA-vLIsBWB3bzJFZwGw2OvY,3190
|
8
8
|
muffin/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
9
|
muffin/pytest.py,sha256=51pJ-JJ2vwqiPhR9TPqXvT78X35l3v3oEkN5LBnfY8E,2679
|
10
10
|
muffin/types.py,sha256=wsUj5oAfqSZMoEf-wyFJLBlWa8Mc-eJGqKLr02HxuXE,153
|
11
11
|
muffin/utils.py,sha256=6Domw0vOVj9hv9NYadaRgfBUgPYhJTMc7sG8VgqszRQ,2905
|
12
|
-
muffin-0.
|
13
|
-
muffin-0.
|
14
|
-
muffin-0.
|
15
|
-
muffin-0.
|
12
|
+
muffin-0.101.0.dist-info/METADATA,sha256=uRLg708m_6wniwKpus-alsRGkWh2ESooG-Tb2SYisVI,11381
|
13
|
+
muffin-0.101.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
14
|
+
muffin-0.101.0.dist-info/entry_points.txt,sha256=GvPS3M-tNVPzhUS5jnUpOmWw2NAqedY34VRCYgPYzlM,84
|
15
|
+
muffin-0.101.0.dist-info/RECORD,,
|
File without changes
|