django-plugin-system 2.0.1__tar.gz → 2.0.2__tar.gz
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.
- {django_plugin_system-2.0.1/src/django_plugin_system.egg-info → django_plugin_system-2.0.2}/PKG-INFO +1 -1
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/pyproject.toml +1 -1
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system/models.py +8 -2
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system/plugin_core.py +51 -14
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2/src/django_plugin_system.egg-info}/PKG-INFO +1 -1
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/LICENSE +0 -0
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/README.md +0 -0
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/setup.cfg +0 -0
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system/__init__.py +0 -0
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system/admin.py +0 -0
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system/apps.py +0 -0
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system/forms.py +0 -0
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system/helpers.py +0 -0
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system/management/__init__.py +0 -0
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system/management/commands/__init__.py +0 -0
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system/management/commands/pluginsync.py +0 -0
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system/migrations/0001_initial.py +0 -0
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system/migrations/__init__.py +0 -0
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system/register.py +0 -0
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system/services/__init__.py +0 -0
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system/services/sync.py +0 -0
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system/signals.py +0 -0
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system/storage.py +0 -0
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system/templates/admin/django_plugin_system/plugininstance/configure.html +0 -0
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system/templates/admin/django_plugin_system/plugininstance/select_item.html +0 -0
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system.egg-info/SOURCES.txt +0 -0
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system.egg-info/dependency_links.txt +0 -0
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system.egg-info/requires.txt +0 -0
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system.egg-info/top_level.txt +0 -0
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/tests/test_plugin_core.py +0 -0
- {django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/tests/test_register_and_sync.py +0 -0
{django_plugin_system-2.0.1/src/django_plugin_system.egg-info → django_plugin_system-2.0.2}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: django-plugin-system
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.2
|
|
4
4
|
Summary: A flexible plugin framework for Django with admin-managed plugin instances and registry-to-database sync.
|
|
5
5
|
Author-email: Alireza Tabatabaeian <alireza.tabatabaeian@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/Alireza-Tabatabaeian/django-plugin-system
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "django-plugin-system"
|
|
7
|
-
version = "2.0.
|
|
7
|
+
version = "2.0.2"
|
|
8
8
|
description = "A flexible plugin framework for Django with admin-managed plugin instances and registry-to-database sync."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
{django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system/models.py
RENAMED
|
@@ -206,9 +206,15 @@ class PluginInstance(models.Model):
|
|
|
206
206
|
)
|
|
207
207
|
|
|
208
208
|
def load_instance(self):
|
|
209
|
-
|
|
210
|
-
|
|
209
|
+
"""
|
|
210
|
+
deprecated since 2.0.2
|
|
211
|
+
will be removed in 3.0.0, use load_implementation instead.
|
|
212
|
+
"""
|
|
213
|
+
return self.load_implementation()
|
|
211
214
|
|
|
215
|
+
def load_implementation(self):
|
|
216
|
+
class_imp = self.item.load_plugin_class()
|
|
217
|
+
return None if class_imp is None else class_imp(self)
|
|
212
218
|
|
|
213
219
|
# Cache invalidation when items change
|
|
214
220
|
@receiver(post_save, sender=PluginInstance)
|
{django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system/plugin_core.py
RENAMED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
from abc import ABC
|
|
2
|
-
from typing import Any, ClassVar, Type
|
|
3
|
-
from typing import Dict
|
|
4
|
+
from typing import Any, ClassVar, Type, TYPE_CHECKING
|
|
4
5
|
|
|
5
6
|
from django.forms import Form
|
|
6
7
|
|
|
8
|
+
if TYPE_CHECKING:
|
|
9
|
+
from .models import PluginInstance
|
|
10
|
+
|
|
7
11
|
|
|
8
12
|
class PluginConfiguration:
|
|
9
13
|
form_class: ClassVar[Type[Form]]
|
|
@@ -46,6 +50,11 @@ class BasePluginType(ABC):
|
|
|
46
50
|
"""
|
|
47
51
|
description about the plugin type (optional), defaults to empty string
|
|
48
52
|
"""
|
|
53
|
+
_plugin_item: BasePluginItem
|
|
54
|
+
|
|
55
|
+
@property
|
|
56
|
+
def plugin_item(self) -> BasePluginItem:
|
|
57
|
+
return self._plugin_item
|
|
49
58
|
|
|
50
59
|
def __init_subclass__(cls, **kwargs):
|
|
51
60
|
super().__init_subclass__(**kwargs)
|
|
@@ -67,6 +76,9 @@ class BasePluginType(ABC):
|
|
|
67
76
|
if not hasattr(cls, 'name'):
|
|
68
77
|
raise TypeError("Plugin type class must have name")
|
|
69
78
|
|
|
79
|
+
def __init__(self, plugin_item: BasePluginItem):
|
|
80
|
+
self._plugin_item = plugin_item
|
|
81
|
+
|
|
70
82
|
|
|
71
83
|
class BasePluginItem:
|
|
72
84
|
name: ClassVar[str]
|
|
@@ -85,17 +97,18 @@ class BasePluginItem:
|
|
|
85
97
|
"""
|
|
86
98
|
the configuration class if the plugin item can be configured (optional but if provides one, it should be a subclass of PluginConfiguration)
|
|
87
99
|
"""
|
|
88
|
-
|
|
89
|
-
"""
|
|
90
|
-
the config of instance
|
|
91
|
-
"""
|
|
100
|
+
_instance: PluginInstance | None
|
|
92
101
|
|
|
93
|
-
def __init__(self,
|
|
94
|
-
self.
|
|
102
|
+
def __init__(self, instance: PluginInstance | None = None) -> None:
|
|
103
|
+
self._instance = instance
|
|
95
104
|
|
|
96
105
|
@property
|
|
97
106
|
def config(self):
|
|
98
|
-
return self.
|
|
107
|
+
return self._instance.config
|
|
108
|
+
|
|
109
|
+
@property
|
|
110
|
+
def plugin_instance(self):
|
|
111
|
+
return self._instance
|
|
99
112
|
|
|
100
113
|
def __init_subclass__(cls, **kwargs):
|
|
101
114
|
super().__init_subclass__(**kwargs)
|
|
@@ -111,11 +124,35 @@ class BasePluginItem:
|
|
|
111
124
|
if not issubclass(plugin_type, BasePluginType):
|
|
112
125
|
raise TypeError("Plugin items must point to a correct type of plugin type through `plugin_type` property")
|
|
113
126
|
else:
|
|
114
|
-
for attr_name
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
127
|
+
for attr_name in plugin_type.__abstractmethods__:
|
|
128
|
+
attr = getattr(cls, attr_name, None)
|
|
129
|
+
if attr is None or not callable(attr):
|
|
130
|
+
raise AttributeError(
|
|
131
|
+
f"Plugin item for {plugin_type.name} must implement {attr_name}"
|
|
132
|
+
)
|
|
118
133
|
# check if class provides a configuration form and then if the form is of correct type
|
|
119
134
|
configuration = getattr(cls, "configuration", None)
|
|
120
|
-
if configuration
|
|
135
|
+
if not isinstance(configuration, type) or not issubclass(configuration, PluginConfiguration):
|
|
121
136
|
raise TypeError("configuration must be a subclass of PluginConfiguration")
|
|
137
|
+
|
|
138
|
+
def __getattr__(self, item):
|
|
139
|
+
if item.startswith("_"):
|
|
140
|
+
raise AttributeError(item)
|
|
141
|
+
|
|
142
|
+
plugin_type_method = self.plugin_type.__dict__.get(item)
|
|
143
|
+
|
|
144
|
+
if plugin_type_method is None:
|
|
145
|
+
raise AttributeError(item)
|
|
146
|
+
|
|
147
|
+
if not callable(plugin_type_method):
|
|
148
|
+
raise AttributeError(item)
|
|
149
|
+
|
|
150
|
+
if getattr(plugin_type_method, "__isabstractmethod__", False):
|
|
151
|
+
raise AttributeError(item)
|
|
152
|
+
|
|
153
|
+
def delegated_method(*args, **kwargs):
|
|
154
|
+
plugin_type_instance = self.plugin_type(self)
|
|
155
|
+
method = getattr(plugin_type_instance, item)
|
|
156
|
+
return method(*args, **kwargs)
|
|
157
|
+
|
|
158
|
+
return delegated_method
|
{django_plugin_system-2.0.1 → django_plugin_system-2.0.2/src/django_plugin_system.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: django-plugin-system
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.2
|
|
4
4
|
Summary: A flexible plugin framework for Django with admin-managed plugin instances and registry-to-database sync.
|
|
5
5
|
Author-email: Alireza Tabatabaeian <alireza.tabatabaeian@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/Alireza-Tabatabaeian/django-plugin-system
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system/helpers.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system/register.py
RENAMED
|
File without changes
|
|
File without changes
|
{django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system/services/sync.py
RENAMED
|
File without changes
|
{django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system/signals.py
RENAMED
|
File without changes
|
{django_plugin_system-2.0.1 → django_plugin_system-2.0.2}/src/django_plugin_system/storage.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|