Permalink
Browse files

fix iteration over installed apps

  • Loading branch information...
alekam committed Jan 7, 2011
1 parent 8c93db0 commit 6ea47961500c501feaeb8c39ade096c98288f4be
@@ -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
@@ -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 = []
@@ -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
@@ -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
@@ -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):

0 comments on commit 6ea4796

Please sign in to comment.