diff --git a/CHANGELOG b/CHANGELOG index 37ca1540c..6916a11b6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,7 +15,7 @@ Files: - Enabled update and delete view for uploader refering to his own files. Other: - Changed widget api. Used new metaclass. -- Changed api for plugins. +- Changed api for plugins. Used entry points to detect them automaticly. - Renamed config api classes. - Renamed some classes of the poll api. - Inserted api for the personal info widget. diff --git a/openslides/global_settings.py b/openslides/global_settings.py index e39cc681d..b95e225a8 100644 --- a/openslides/global_settings.py +++ b/openslides/global_settings.py @@ -5,6 +5,7 @@ import os from django.utils.translation import ugettext_lazy from openslides.utils.main import filesystem2unicode +from openslides.utils.plugins import get_plugins_from_entry_points SITE_ROOT = os.path.realpath(os.path.dirname(__file__)) @@ -125,3 +126,6 @@ HAYSTACK_CONNECTIONS = { # Haystack updates search index after each save/delete action by apps HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor' + +# Adds all automaticly collected plugins +INSTALLED_PLUGINS = get_plugins_from_entry_points() diff --git a/openslides/utils/plugins.py b/openslides/utils/plugins.py index 19ccfdbde..d494de0f8 100644 --- a/openslides/utils/plugins.py +++ b/openslides/utils/plugins.py @@ -1,10 +1,20 @@ # -*- coding: utf-8 -*- from django.utils.importlib import import_module +from pkg_resources import iter_entry_points plugins = {} +def get_plugins_from_entry_points(): + """ + Collects all entry points in the group openslides_plugins from all + distributions in the default working set and returns their module names as + tuple. + """ + return tuple(entry_point.module_name for entry_point in iter_entry_points('openslides_plugins')) + + def get_plugin(plugin): """ Returns the imported module. The plugin argument must be a python dotted diff --git a/openslides/utils/settings.py.tpl b/openslides/utils/settings.py.tpl index 5e1dac515..10ad6dbb9 100644 --- a/openslides/utils/settings.py.tpl +++ b/openslides/utils/settings.py.tpl @@ -27,7 +27,7 @@ DATABASES = { 'PORT': ''}} # Add OpenSlides plugins to this list (see example entry in comment) -INSTALLED_PLUGINS = ( +INSTALLED_PLUGINS += ( # 'pluginname', ) diff --git a/requirements_production.txt b/requirements_production.txt index 7bda20411..ff4343e08 100644 --- a/requirements_production.txt +++ b/requirements_production.txt @@ -7,6 +7,7 @@ django-mptt>=0.6,<0.7 jsonfield>=0.9,<0.10 pillow>=2.2,<2.3 reportlab>=2.7,<2.8 +setuptools>=2.1,<2.2 sockjs-tornado>=1.0,<1.1 tornado>=3.1,<3.2 whoosh>=2.5,<2.6