Esempio n. 1
0
def is_middleware_class(middleware_class, middleware_path):
    try:
        middleware_cls = import_string(middleware_path)
    except ImportError:
        return
    return inspect.isclass(middleware_cls) and issubclass(
        middleware_cls, middleware_class
    )
Esempio n. 2
0
def get_show_toolbar():
    # If SHOW_TOOLBAR_CALLBACK is a string, which is the recommended
    # setup, resolve it to the corresponding callable.
    func_or_path = dt_settings.get_config()["SHOW_TOOLBAR_CALLBACK"]
    if isinstance(func_or_path, six.string_types):
        return import_string(func_or_path)
    else:
        return func_or_path
Esempio n. 3
0
 def get_panel_classes(cls):
     if cls._panel_classes is None:
         # Load panels in a temporary variable for thread safety.
         panel_classes = [
             import_string(panel_path) for panel_path in dt_settings.get_panels()
         ]
         cls._panel_classes = panel_classes
     return cls._panel_classes
Esempio n. 4
0
 def gen_app_versions(self):
     for name in settings.INSTALLED_APPS:
         try:
             app = import_string(name)
         except:
             continue
         version = self.get_app_version(app)
         if version:
             yield app.__name__, name, version
Esempio n. 5
0
 def gen_app_versions(self):
     for name in settings.INSTALLED_APPS:
         try:
             app = import_string(name)
         except:
             continue
         version = self.get_app_version(app)
         if version:
             yield app.__name__, name, version
Esempio n. 6
0
 def signals(self):
     signals = self.SIGNALS.copy()
     for signal in self.toolbar.config["EXTRA_SIGNALS"]:
         signal_name = signal.rsplit(".", 1)[-1]
         signals[signal_name] = import_string(signal)
     return signals
Esempio n. 7
0
 def signals(self):
     signals = self.SIGNALS.copy()
     for signal in self.toolbar.config["EXTRA_SIGNALS"]:
         signal_name = signal.rsplit(".", 1)[-1]
         signals[signal_name] = import_string(signal)
     return signals