diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-12-24 12:25:17 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-12-24 12:25:17 +0100 |
| commit | 1716b7ce5a02b2a77188dfea2d41e25dfa58821c (patch) | |
| tree | f3422c0d6725f45756a3b9deb32406d319b8a72e /django/core/management/commands | |
| parent | e9e522a8e7455900a775678e5d6bc518a289b8d1 (diff) | |
Renamed AppCache to Apps.
Also renamed app_cache to apps and "app cache" to "app registry".
Deprecated AppCache.app_cache_ready() in favor of Apps.ready().
Diffstat (limited to 'django/core/management/commands')
| -rw-r--r-- | django/core/management/commands/dumpdata.py | 20 | ||||
| -rw-r--r-- | django/core/management/commands/flush.py | 6 | ||||
| -rw-r--r-- | django/core/management/commands/loaddata.py | 4 | ||||
| -rw-r--r-- | django/core/management/commands/makemigrations.py | 6 | ||||
| -rw-r--r-- | django/core/management/commands/migrate.py | 34 | ||||
| -rw-r--r-- | django/core/management/commands/shell.py | 4 | ||||
| -rw-r--r-- | django/core/management/commands/sqlsequencereset.py | 4 |
7 files changed, 39 insertions, 39 deletions
diff --git a/django/core/management/commands/dumpdata.py b/django/core/management/commands/dumpdata.py index 9aebb6c7d6..f6b9e7a4c8 100644 --- a/django/core/management/commands/dumpdata.py +++ b/django/core/management/commands/dumpdata.py @@ -37,7 +37,7 @@ class Command(BaseCommand): args = '[appname appname.ModelName ...]' def handle(self, *app_labels, **options): - from django.apps import app_cache + from django.apps import apps format = options.get('format') indent = options.get('indent') @@ -63,13 +63,13 @@ class Command(BaseCommand): for exclude in excludes: if '.' in exclude: app_label, model_name = exclude.split('.', 1) - model_obj = app_cache.get_model(app_label, model_name) + model_obj = apps.get_model(app_label, model_name) if not model_obj: raise CommandError('Unknown model in excludes: %s' % exclude) excluded_models.add(model_obj) else: try: - app_obj = app_cache.get_app_config(exclude).models_module + app_obj = apps.get_app_config(exclude).models_module if app_obj is not None: excluded_apps.add(app_obj) except LookupError: @@ -79,7 +79,7 @@ class Command(BaseCommand): if primary_keys: raise CommandError("You can only use --pks option with one model") app_list = OrderedDict((app_config.models_module, None) - for app_config in app_cache.get_app_configs(only_with_models_module=True) + for app_config in apps.get_app_configs(only_with_models_module=True) if app_config.models_module not in excluded_apps) else: if len(app_labels) > 1 and primary_keys: @@ -89,12 +89,12 @@ class Command(BaseCommand): try: app_label, model_label = label.split('.') try: - app = app_cache.get_app_config(app_label).models_module + app = apps.get_app_config(app_label).models_module except LookupError: raise CommandError("Unknown application: %s" % app_label) if app is None or app in excluded_apps: continue - model = app_cache.get_model(app_label, model_label) + model = apps.get_model(app_label, model_label) if model is None: raise CommandError("Unknown model: %s.%s" % (app_label, model_label)) @@ -109,7 +109,7 @@ class Command(BaseCommand): # This is just an app - no model qualifier app_label = label try: - app = app_cache.get_app_config(app_label).models_module + app = apps.get_app_config(app_label).models_module except LookupError: raise CommandError("Unknown application: %s" % app_label) if app is None or app in excluded_apps: @@ -162,13 +162,13 @@ def sort_dependencies(app_list): is serialized before a normal model, and any model with a natural key dependency has it's dependencies serialized first. """ - from django.apps import app_cache + from django.apps import apps # Process the list of models, and get the list of dependencies model_dependencies = [] models = set() for app, model_list in app_list: if model_list is None: - model_list = app_cache.get_models(app) + model_list = apps.get_models(app) for model in model_list: models.add(model) @@ -176,7 +176,7 @@ def sort_dependencies(app_list): if hasattr(model, 'natural_key'): deps = getattr(model.natural_key, 'dependencies', []) if deps: - deps = [app_cache.get_model(*d.split('.')) for d in deps] + deps = [apps.get_model(*d.split('.')) for d in deps] else: deps = [] diff --git a/django/core/management/commands/flush.py b/django/core/management/commands/flush.py index 49007bf0a2..619df9536c 100644 --- a/django/core/management/commands/flush.py +++ b/django/core/management/commands/flush.py @@ -2,7 +2,7 @@ import sys from importlib import import_module from optparse import make_option -from django.apps import app_cache +from django.apps import apps from django.db import connections, router, transaction, DEFAULT_DB_ALIAS from django.core.management import call_command from django.core.management.base import NoArgsCommand, CommandError @@ -41,7 +41,7 @@ class Command(NoArgsCommand): # Import the 'management' module within each installed app, to register # dispatcher events. - for app_config in app_cache.get_app_configs(): + for app_config in apps.get_app_configs(): try: import_module('.management', app_config.name) except ImportError: @@ -93,6 +93,6 @@ Are you sure you want to do this? # Emit the post migrate signal. This allows individual applications to # respond as if the database had been migrated from scratch. all_models = [] - for app_config in app_cache.get_app_configs(only_with_models_module=True): + for app_config in apps.get_app_configs(only_with_models_module=True): all_models.extend(router.get_migratable_models(app_config.models_module, database, include_auto_created=True)) emit_post_migrate_signal(set(all_models), verbosity, interactive, database) diff --git a/django/core/management/commands/loaddata.py b/django/core/management/commands/loaddata.py index bfeba68aa6..65bc96ba99 100644 --- a/django/core/management/commands/loaddata.py +++ b/django/core/management/commands/loaddata.py @@ -7,7 +7,7 @@ import warnings import zipfile from optparse import make_option -from django.apps import app_cache +from django.apps import apps from django.conf import settings from django.core import serializers from django.core.management.base import BaseCommand, CommandError @@ -230,7 +230,7 @@ class Command(BaseCommand): current directory. """ dirs = [] - for app_config in app_cache.get_app_configs(): + for app_config in apps.get_app_configs(): d = os.path.join(app_config.path, 'fixtures') if os.path.isdir(d): dirs.append(d) diff --git a/django/core/management/commands/makemigrations.py b/django/core/management/commands/makemigrations.py index aaf0270840..411aec42b3 100644 --- a/django/core/management/commands/makemigrations.py +++ b/django/core/management/commands/makemigrations.py @@ -3,7 +3,7 @@ import os import operator from optparse import make_option -from django.apps import app_cache +from django.apps import apps from django.core.management.base import BaseCommand, CommandError from django.db import connections, DEFAULT_DB_ALIAS, migrations from django.db.migrations.loader import MigrationLoader @@ -37,7 +37,7 @@ class Command(BaseCommand): bad_app_labels = set() for app_label in app_labels: try: - app_cache.get_app_config(app_label) + apps.get_app_config(app_label) except LookupError: bad_app_labels.add(app_label) if bad_app_labels: @@ -72,7 +72,7 @@ class Command(BaseCommand): # Detect changes autodetector = MigrationAutodetector( loader.graph.project_state(), - ProjectState.from_app_cache(app_cache), + ProjectState.from_apps(apps), InteractiveMigrationQuestioner(specified_apps=app_labels), ) changes = autodetector.changes(graph=loader.graph, trim_to_apps=app_labels or None) diff --git a/django/core/management/commands/migrate.py b/django/core/management/commands/migrate.py index 05b4a62e87..1f5e9619c7 100644 --- a/django/core/management/commands/migrate.py +++ b/django/core/management/commands/migrate.py @@ -6,7 +6,7 @@ from importlib import import_module import itertools import traceback -from django.apps import app_cache +from django.apps import apps from django.core.management import call_command from django.core.management.base import BaseCommand, CommandError from django.core.management.color import no_style @@ -46,7 +46,7 @@ class Command(BaseCommand): # Import the 'management' module within each installed app, to register # dispatcher events. - for app_config in app_cache.get_app_configs(): + for app_config in apps.get_app_configs(): if module_has_submodule(app_config.app_module, "management"): import_module('.management', app_config.name) @@ -135,7 +135,7 @@ class Command(BaseCommand): # If there's changes that aren't in migrations yet, tell them how to fix it. autodetector = MigrationAutodetector( executor.loader.graph.project_state(), - ProjectState.from_app_cache(app_cache), + ProjectState.from_apps(apps), ) changes = autodetector.changes(graph=executor.loader.graph) if changes: @@ -167,8 +167,8 @@ class Command(BaseCommand): else: self.stdout.write(self.style.MIGRATE_SUCCESS(" OK")) - def sync_apps(self, connection, apps): - "Runs the old syncdb-style operation on a list of apps." + def sync_apps(self, connection, app_labels): + "Runs the old syncdb-style operation on a list of app_labels." cursor = connection.cursor() # Get a list of already installed *models* so that references work right. @@ -181,8 +181,8 @@ class Command(BaseCommand): all_models = [ (app_config.label, router.get_migratable_models(app_config.models_module, connection.alias, include_auto_created=True)) - for app_config in app_cache.get_app_configs(only_with_models_module=True) - if app_config.label in apps + for app_config in apps.get_app_configs(only_with_models_module=True) + if app_config.label in app_labels ] def model_installed(model): @@ -277,7 +277,7 @@ class Command(BaseCommand): return created_models - def show_migration_list(self, connection, apps=None): + def show_migration_list(self, connection, app_names=None): """ Shows a list of all migrations on the system, or only those of some named apps. @@ -286,24 +286,24 @@ class Command(BaseCommand): loader = MigrationLoader(connection) graph = loader.graph # If we were passed a list of apps, validate it - if apps: + if app_names: invalid_apps = [] - for app in apps: - if app not in loader.migrated_apps: - invalid_apps.append(app) + for app_name in app_names: + if app_name not in loader.migrated_apps: + invalid_apps.append(app_name) if invalid_apps: raise CommandError("No migrations present for: %s" % (", ".join(invalid_apps))) # Otherwise, show all apps in alphabetic order else: - apps = sorted(loader.migrated_apps) + app_names = sorted(loader.migrated_apps) # For each app, print its migrations in order from oldest (roots) to # newest (leaves). - for app in apps: - self.stdout.write(app, self.style.MIGRATE_LABEL) + for app_name in app_names: + self.stdout.write(app_name, self.style.MIGRATE_LABEL) shown = set() - for node in graph.leaf_nodes(app): + for node in graph.leaf_nodes(app_name): for plan_node in graph.forwards_plan(node): - if plan_node not in shown and plan_node[0] == app: + if plan_node not in shown and plan_node[0] == app_name: # Give it a nice title if it's a squashed one title = plan_node[1] if graph.nodes[plan_node].replaces: diff --git a/django/core/management/commands/shell.py b/django/core/management/commands/shell.py index 12af814161..149b9edd89 100644 --- a/django/core/management/commands/shell.py +++ b/django/core/management/commands/shell.py @@ -66,8 +66,8 @@ class Command(NoArgsCommand): def handle_noargs(self, **options): # XXX: (Temporary) workaround for ticket #1796: force early loading of all # models from installed apps. - from django.apps import app_cache - app_cache.get_models() + from django.apps import apps + apps.get_models() use_plain = options.get('plain', False) no_startup = options.get('no_startup', False) diff --git a/django/core/management/commands/sqlsequencereset.py b/django/core/management/commands/sqlsequencereset.py index 24ec25e8ed..58f171e87b 100644 --- a/django/core/management/commands/sqlsequencereset.py +++ b/django/core/management/commands/sqlsequencereset.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals from optparse import make_option -from django.apps import app_cache +from django.apps import apps from django.core.management.base import AppCommand from django.db import connections, DEFAULT_DB_ALIAS @@ -21,4 +21,4 @@ class Command(AppCommand): def handle_app(self, app, **options): connection = connections[options.get('database')] - return '\n'.join(connection.ops.sequence_reset_sql(self.style, app_cache.get_models(app, include_auto_created=True))) + return '\n'.join(connection.ops.sequence_reset_sql(self.style, apps.get_models(app, include_auto_created=True))) |
