general: use django.apps to register URLs and actions (#6979)

This commit is contained in:
Frédéric Péters 2015-04-18 14:26:00 +02:00
parent b5fee77f5e
commit 6c86f26186
2 changed files with 5 additions and 12 deletions

View File

@ -13,7 +13,3 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from . import plugins
plugins.init()

View File

@ -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()