Skip to content
This repository has been archived by the owner on Mar 29, 2023. It is now read-only.

Commit

Permalink
Remove django-load dependency
Browse files Browse the repository at this point in the history
This library was outdated, not supporting neither Python3 nor
Django 1.11. This patch adds the same functionality using
Django API instead.
  • Loading branch information
sduenas committed Sep 5, 2017
1 parent df4ff6d commit 2920afd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
1 change: 0 additions & 1 deletion setup.py
Expand Up @@ -16,7 +16,6 @@
'python-memcached',
'jsonfield',
'logutils', # required for django-medusa
'django-load',
'django-compressor',
'django-bootstrap-form',
'django-sekizai',
Expand Down
18 changes: 15 additions & 3 deletions wsgi/healthmeter/importerutils/registry.py
Expand Up @@ -2,9 +2,13 @@
# License: GPLv3 or any later version

import collections
import logging

from django.apps import apps
from django_load.core import load
from django.utils.module_loading import import_module


logger = logging.getLogger(__name__)


ImporterEntry = collections.namedtuple('ImporterEntry', ['cls', 'key'])
Expand Down Expand Up @@ -36,7 +40,6 @@ def lookup_importer(model):
for key, value in importers_by_model.items():
if key in model.__mro__:
return value

raise e


Expand All @@ -53,8 +56,17 @@ def load_importer_modules():
Import .importers for each app in INSTALLED_APPS
"""
global _importers_loaded

if _importers_loaded:
return

load('importers')
for app_cfg in apps.get_app_configs():
module_name = '%s.%s' % (app_cfg.name, 'importers')

try:
import_module(module_name)
except ImportError:
logger.warning("Importing %s app importers %s module",
app_cfg.name, module_name)

_importers_loaded = True

0 comments on commit 2920afd

Please sign in to comment.