mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-28 08:03:36 +00:00
introduced signals for pre/post-module-loading
This commit is contained in:
parent
770e4c00fd
commit
53adac652b
@ -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):
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
|
||||
27
plinth/signals.py
Normal file
27
plinth/signals.py
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
"""
|
||||
Plinth signals
|
||||
"""
|
||||
|
||||
from django.dispatch import Signal
|
||||
|
||||
|
||||
service_enabled = Signal(providing_args=['service_id', 'enabled'])
|
||||
pre_module_loading = Signal()
|
||||
post_module_loading = Signal()
|
||||
Loading…
x
Reference in New Issue
Block a user