general: remove plugin discovery via pkg_resources (#25040)
This commit is contained in:
parent
a26e3b57f5
commit
57860d5699
|
@ -15,7 +15,6 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from functools import wraps
|
||||
from pkg_resources import iter_entry_points
|
||||
import logging
|
||||
|
||||
from django.apps import apps
|
||||
|
@ -49,17 +48,6 @@ def get_plugin_includes(plugin, url_serie):
|
|||
from .urls_utils import decorated_includes
|
||||
return url('^', decorated_includes(plugin_enabled, include(urls)))
|
||||
|
||||
def get_plugins(*args, **kwargs):
|
||||
plugins = []
|
||||
for entrypoint in iter_entry_points(PLUGIN_GROUP_NAME):
|
||||
try:
|
||||
plugin = entrypoint.load()
|
||||
except Exception, e:
|
||||
logger.exception('failed to load entrypoint %s', entrypoint)
|
||||
raise PluginError('failed to load entrypoint %s' % entrypoint, e)
|
||||
plugins.append(plugin(*args, **kwargs))
|
||||
return plugins
|
||||
|
||||
def register_plugins_urls(urlpatterns):
|
||||
pre_urls = []
|
||||
post_urls = []
|
||||
|
@ -84,14 +72,6 @@ def register_plugins_manager_urls(urlpatterns):
|
|||
post_urls.append(urls)
|
||||
return pre_urls + urlpatterns + post_urls
|
||||
|
||||
def register_plugins_apps(installed_apps):
|
||||
installed_apps = tuple(installed_apps)
|
||||
for plugin in get_plugins():
|
||||
if hasattr(plugin, 'get_apps'):
|
||||
installed_apps += tuple(app for app in plugin.get_apps()
|
||||
if app not in installed_apps)
|
||||
return installed_apps
|
||||
|
||||
def get_extra_manager_actions():
|
||||
'''This iterates over all appconfigs and returns a list of dictionaries,
|
||||
with href and text keys.'''
|
||||
|
|
|
@ -27,8 +27,6 @@ import os
|
|||
from django.conf import global_settings
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from . import plugins
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
||||
|
||||
|
@ -86,8 +84,6 @@ INSTALLED_APPS = (
|
|||
'xstatic.pkg.leaflet_markercluster',
|
||||
)
|
||||
|
||||
INSTALLED_APPS = plugins.register_plugins_apps(INSTALLED_APPS)
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
'combo.middleware.GlobalRequestMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
|
|
Loading…
Reference in New Issue