0001-general-remove-plugin-discovery-via-pkg_resources-25.patch
combo/plugins.py | ||
---|---|---|
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | |
17 | 17 |
from functools import wraps |
18 |
from pkg_resources import iter_entry_points |
|
19 | 18 |
import logging |
20 | 19 | |
21 | 20 |
from django.apps import apps |
... | ... | |
49 | 48 |
from .urls_utils import decorated_includes |
50 | 49 |
return url('^', decorated_includes(plugin_enabled, include(urls))) |
51 | 50 | |
52 |
def get_plugins(*args, **kwargs): |
|
53 |
plugins = [] |
|
54 |
for entrypoint in iter_entry_points(PLUGIN_GROUP_NAME): |
|
55 |
try: |
|
56 |
plugin = entrypoint.load() |
|
57 |
except Exception, e: |
|
58 |
logger.exception('failed to load entrypoint %s', entrypoint) |
|
59 |
raise PluginError('failed to load entrypoint %s' % entrypoint, e) |
|
60 |
plugins.append(plugin(*args, **kwargs)) |
|
61 |
return plugins |
|
62 | ||
63 | 51 |
def register_plugins_urls(urlpatterns): |
64 | 52 |
pre_urls = [] |
65 | 53 |
post_urls = [] |
... | ... | |
84 | 72 |
post_urls.append(urls) |
85 | 73 |
return pre_urls + urlpatterns + post_urls |
86 | 74 | |
87 |
def register_plugins_apps(installed_apps): |
|
88 |
installed_apps = tuple(installed_apps) |
|
89 |
for plugin in get_plugins(): |
|
90 |
if hasattr(plugin, 'get_apps'): |
|
91 |
installed_apps += tuple(app for app in plugin.get_apps() |
|
92 |
if app not in installed_apps) |
|
93 |
return installed_apps |
|
94 | ||
95 | 75 |
def get_extra_manager_actions(): |
96 | 76 |
'''This iterates over all appconfigs and returns a list of dictionaries, |
97 | 77 |
with href and text keys.''' |
combo/settings.py | ||
---|---|---|
27 | 27 |
from django.conf import global_settings |
28 | 28 |
from django.utils.translation import ugettext_lazy as _ |
29 | 29 | |
30 |
from . import plugins |
|
31 | ||
32 | 30 |
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) |
33 | 31 |
BASE_DIR = os.path.dirname(os.path.dirname(__file__)) |
34 | 32 | |
... | ... | |
86 | 84 |
'xstatic.pkg.leaflet_markercluster', |
87 | 85 |
) |
88 | 86 | |
89 |
INSTALLED_APPS = plugins.register_plugins_apps(INSTALLED_APPS) |
|
90 | ||
91 | 87 |
MIDDLEWARE_CLASSES = ( |
92 | 88 |
'combo.middleware.GlobalRequestMiddleware', |
93 | 89 |
'django.contrib.sessions.middleware.SessionMiddleware', |
94 |
- |