From 6c86f26186d3e2c2f198b23431cb17100e562b31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sat, 18 Apr 2015 14:26:00 +0200 Subject: [PATCH] general: use django.apps to register URLs and actions (#6979) --- combo/__init__.py | 4 ---- combo/plugins.py | 13 +++++-------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/combo/__init__.py b/combo/__init__.py index 0eb735bd..f6e18caf 100644 --- a/combo/__init__.py +++ b/combo/__init__.py @@ -13,7 +13,3 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . - -from . import plugins - -plugins.init() diff --git a/combo/plugins.py b/combo/plugins.py index f50ecf35..3ab487aa 100644 --- a/combo/plugins.py +++ b/combo/plugins.py @@ -17,7 +17,9 @@ from pkg_resources import iter_entry_points import logging +from django.apps import apps from django.conf.urls import patterns, include, url +from django.conf import settings logger = logging.getLogger(__name__) @@ -41,7 +43,7 @@ def get_plugins(*args, **kwargs): def register_plugins_urls(urlpatterns): pre_urls = [] post_urls = [] - for plugin in get_plugins(): + for plugin in apps.get_app_configs(): if hasattr(plugin, 'get_before_urls'): urls = plugin.get_before_urls() if urls: @@ -74,15 +76,10 @@ def register_plugins_middleware(middlewares): return middlewares def get_extra_manager_actions(): - '''This iterates over all plugins and returns a list of dictionaries, + '''This iterates over all appconfigs and returns a list of dictionaries, with href and text keys.''' actions = [] - for plugin in get_plugins(): + for plugin in apps.get_app_configs(): if hasattr(plugin, 'get_extra_manager_actions'): actions.extend(plugin.get_extra_manager_actions()) return actions - -def init(): - for plugin in get_plugins(): - if hasattr(plugin, 'init'): - plugin.init()