diff --git a/plinth/module_loader.py b/plinth/module_loader.py index b552d2260..78d610176 100644 --- a/plinth/module_loader.py +++ b/plinth/module_loader.py @@ -26,6 +26,7 @@ import os from plinth import cfg from plinth import urls +from plinth.signals import pre_module_loading, post_module_loading LOGGER = logging.getLogger(__name__) @@ -37,6 +38,7 @@ def load_modules(): Read names of enabled modules in modules/enabled directory and import them from modules directory. """ + pre_module_loading.send_robust(sender="module_loader") module_names = [] modules = {} directory = os.path.dirname(os.path.abspath(__file__)) @@ -75,6 +77,8 @@ def load_modules(): for module_name in ordered_modules: _initialize_module(modules[module_name]) LOADED_MODULES.append(module_name) + post_module_loading.send_robust(sender="module_loader") + def _insert_modules(module_name, module, remaining_modules, ordered_modules): diff --git a/plinth/modules/firewall/firewall.py b/plinth/modules/firewall/firewall.py index 5062488db..633f2d665 100644 --- a/plinth/modules/firewall/firewall.py +++ b/plinth/modules/firewall/firewall.py @@ -26,6 +26,7 @@ import logging from plinth import actions from plinth import cfg +from plinth.signals import service_enabled import plinth.service as service_module @@ -37,7 +38,7 @@ def init(): menu = cfg.main_menu.get('system:index') menu.add_urlname(_('Firewall'), 'icon-flag', 'firewall:index', 50) - service_module.ENABLED.connect(on_service_enabled) + service_enabled.connect(on_service_enabled) @login_required diff --git a/plinth/service.py b/plinth/service.py index 30d9cdf06..a8127052f 100644 --- a/plinth/service.py +++ b/plinth/service.py @@ -23,7 +23,8 @@ from gettext import gettext as _ import django.dispatch -ENABLED = django.dispatch.Signal(providing_args=['service_id', 'enabled']) +from plinth.signals import service_enabled + SERVICES = {} @@ -63,7 +64,7 @@ class Service(object): if not callable(self._enabled): self._enabled = enabled - ENABLED.send_robust(sender=sender, service_id=self.service_id, + service_enabled.send_robust(sender=sender, service_id=self.service_id, enabled=enabled) diff --git a/plinth/signals.py b/plinth/signals.py new file mode 100644 index 000000000..f02002289 --- /dev/null +++ b/plinth/signals.py @@ -0,0 +1,27 @@ +# +# This file is part of Plinth. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +""" +Plinth signals +""" + +from django.dispatch import Signal + + +service_enabled = Signal(providing_args=['service_id', 'enabled']) +pre_module_loading = Signal() +post_module_loading = Signal()