Commit 5dfec4e2 authored by Aymeric Augustin's avatar Aymeric Augustin
Browse files

Checked unicity of app config names when populating the app registry.

This check will miss duplicates until the check for duplicate labels is
added.

Refs #21679.
parent 55350013
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
from collections import defaultdict, OrderedDict
from collections import Counter, defaultdict, OrderedDict
import os
import sys
import warnings
@@ -79,8 +79,19 @@ class Apps(object):
                    app_config = entry
                else:
                    app_config = AppConfig.create(entry)
                # TODO: check for duplicate app labels here (#21679).
                self.app_configs[app_config.label] = app_config

            # Check for duplicate app names.
            counts = Counter(
                app_config.name for app_config in self.app_configs.values())
            duplicates = [
                name for name, count in counts.most_common() if count > 1]
            if duplicates:
                raise ImproperlyConfigured(
                    "Application names aren't unique, "
                    "duplicates: %s" % ", ".join(duplicates))

            # Load models.
            for app_config in self.app_configs.values():
                all_models = self.all_models[app_config.label]