Author: arthurk
Date: 2010-08-11 07:26:15 -0500 (Wed, 11 Aug 2010)
New Revision: 13573
Modified:
django/branches/soc2010/app-loading/django/core/apps.py
django/branches/soc2010/app-loading/tests/appcachetests/runtests.py
Log:
[soc2010/app-loading] store normalized version of INSTALLED_APPS in appcache
Modified: django/branches/soc2010/app-loading/django/core/apps.py
===================================================================
--- django/branches/soc2010/app-loading/django/core/apps.py 2010-08-11
12:02:40 UTC (rev 13572)
+++ django/branches/soc2010/app-loading/django/core/apps.py 2010-08-11
12:26:15 UTC (rev 13573)
@@ -40,6 +40,11 @@
# List of App instances
app_instances = [],
+ # Normalized list of INSTALLED_APPS
+ # This stores the module name of settings.INSTALLED_APPS
+ # e.g. 'django.contrib.auth' for 'django.contrib.auth.AuthApp'
+ installed_apps = [],
+
# Mapping of app_labels to a dictionary of model names to model code.
app_models = SortedDict(),
@@ -105,11 +110,13 @@
app_instance = self.find_app(app_name)
if not app_instance:
if '.' in app_name:
+ # get the app label from the full path
app_instance_name = app_name.rsplit('.', 1)[1]
else:
app_instance_name = app_name
app_instance = app_class(app_instance_name)
self.app_instances.append(app_instance)
+ self.installed_apps.append(app_name)
# check if the app instance specifies a path to models
# if not, we use the models.py file from the package dir
Modified: django/branches/soc2010/app-loading/tests/appcachetests/runtests.py
===================================================================
--- django/branches/soc2010/app-loading/tests/appcachetests/runtests.py
2010-08-11 12:02:40 UTC (rev 13572)
+++ django/branches/soc2010/app-loading/tests/appcachetests/runtests.py
2010-08-11 12:26:15 UTC (rev 13573)
@@ -42,6 +42,7 @@
# because thread.RLock is un(deep)copyable
cache.app_models = SortedDict()
cache.app_instances = []
+ cache.installed_apps = []
cache.loaded = False
cache.handled = {}
@@ -272,6 +273,15 @@
"""
self.assertRaises(ImportError, cache.load_app, 'garageland')
+ def test_installed_apps(self):
+ """
+ Test that the installed_apps attribute is populated correctly
+ """
+ settings.INSTALLED_APPS = ('model_app', 'nomodel_app.MyApp',)
+ # populate cache
+ cache.get_app_errors()
+ self.assertEqual(cache.installed_apps, ['model_app', 'nomodel_app',])
+
class RegisterModelsTests(AppCacheTestCase):
"""Tests for the register_models function"""
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.