Skip to content

Commit

Permalink
fix iteration over installed apps
Browse files Browse the repository at this point in the history
  • Loading branch information
alekam committed Jan 7, 2011
1 parent 8c93db0 commit 6ea4796
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
5 changes: 2 additions & 3 deletions django/contrib/admin/__init__.py
Expand Up @@ -16,13 +16,12 @@ def autodiscover():
from django.utils.importlib import import_module
from django.utils.module_loading import module_has_submodule

for app in cache.installed_apps:
app_instance = cache.find_app(app)
for app_instance in cache.app_instances:
mod = app_instance.module
# Attempt to import the app's admin module.
try:
before_import_registry = copy.copy(site._registry)
import_module('%s.admin' % app)
import_module('%s.admin' % app_instance.path)
except:
# Reset the model registry to the state before the last import as
# this import will have to reoccur on the next request and this
Expand Down
8 changes: 4 additions & 4 deletions django/core/management/__init__.py
Expand Up @@ -98,7 +98,7 @@ def get_commands():
# Find the installed apps
try:
from django.core.apps import cache
apps = cache.installed_apps
apps = cache.app_instances
except (AttributeError, EnvironmentError, ImportError):
apps = []

Expand All @@ -111,10 +111,10 @@ def get_commands():
project_directory = None

# Find and load the management module for each installed app.
for app_name in apps:
for app in apps:
try:
path = find_management_module(app_name)
_commands.update(dict([(name, app_name)
path = find_management_module(app.path)
_commands.update(dict([(name, app.path)
for name in find_commands(path)]))
except ImportError:
pass # No management module - ignore this app
Expand Down
4 changes: 2 additions & 2 deletions django/core/management/commands/syncdb.py
Expand Up @@ -31,9 +31,9 @@ def handle_noargs(self, **options):

# Import the 'management' module within each installed app, to register
# dispatcher events.
for app_name in cache.installed_apps:
for app in cache.app_instances:
try:
import_module('.management', app_name)
import_module('.management', app.path)
except ImportError, exc:
# This is slightly hackish. We want to ignore ImportErrors
# if the "management" module itself is missing -- but we don't
Expand Down
3 changes: 1 addition & 2 deletions django/template/loaders/app_directories.py
Expand Up @@ -17,8 +17,7 @@
# At compile time, cache the directories to search.
fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding()
app_template_dirs = []
for app in cache.installed_apps:
app_instance = cache.find_app(app)
for app_instance in cache.app_instances:
mod = app_instance.module
template_dir = os.path.join(os.path.dirname(mod.__file__), 'templates')
if os.path.isdir(template_dir):
Expand Down

0 comments on commit 6ea4796

Please sign in to comment.