From 5d2747818327e0bfab80632a4ef8e71afb84dd39 Mon Sep 17 00:00:00 2001 From: Sergey Pikhovkin Date: Fri, 7 Dec 2018 00:55:44 +0300 Subject: [PATCH] Fix dash.staticfiles.finders.DashComponentSuitesFinder --- dash/staticfiles/finders.py | 23 +++++++++++++++++++++++ dash/version.py | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/dash/staticfiles/finders.py b/dash/staticfiles/finders.py index 49c69f1..e41c69c 100644 --- a/dash/staticfiles/finders.py +++ b/dash/staticfiles/finders.py @@ -1,20 +1,43 @@ from __future__ import print_function +import os +import pkgutil import sys from collections import OrderedDict +from importlib import import_module from django.contrib.staticfiles import utils from django.core.files.storage import FileSystemStorage from django.contrib.staticfiles.finders import FileSystemFinder +from django.apps import apps from ..development.base_component import ComponentRegistry +def _import_module(pkg, m): + try: + _pkg = import_module('.' + m, package=pkg) + except ImportError: + return + + views_path = os.path.dirname(_pkg.__file__) + for info in pkgutil.iter_modules([views_path]): + _import_module(pkg + '.' + m, info[1]) + + class DashComponentSuitesFinder(FileSystemFinder): prefix = '_dash-component-suites/' ignore_patterns = ['*.py', '*.pyc', '*.json'] def __init__(self, *args, **kwargs): # pylint: disable=super-init-not-called + # Import all modules that Dash components were registered in ComponentRegistry + for app in apps.app_configs.keys(): + _import_module(app, 'views') + + if 'dash_renderer' in sys.modules: + # Add dash_renderer manually because it is not a component + ComponentRegistry.registry.add('dash_renderer') + self.locations = [] self.storages = OrderedDict() diff --git a/dash/version.py b/dash/version.py index ef72cc0..4ca39e7 100644 --- a/dash/version.py +++ b/dash/version.py @@ -1 +1 @@ -__version__ = '0.8.1' +__version__ = '0.8.2'