8000 [soc2010/app-loading] removed app_store attribute · ddriddle/django@6f4fc60 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6f4fc60

Browse files
committed
[soc2010/app-loading] removed app_store attribute
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/app-loading@13404 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent 06f15e4 commit 6f4fc60

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

django/db/models/loading.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ class AppCache(object):
2626
# List of App instances
2727
app_instances = [],
2828

29-
# Keys of app_store are the model modules for each application.
30-
app_store = SortedDict(),
31-
3229
# Mapping of app_labels to a dictionary of model names to model code.
3330
app_models = SortedDict(),
3431

@@ -104,11 +101,9 @@ def load_app(self, app_name, can_postpone=False):
104101
raise
105102

106103
self.nesting_level -= 1
107-
if models not in self.app_store:
108-
self.app_store[models] = len(self.app_store)
109-
app = self.find_app(app_name.split('.')[-1])
110-
if app:
111-
app.models_module = models
104+
app = self.find_app(app_name.split('.')[-1])
105+
if app and models is not app.models_module:
106+
app.models_module = models
112107
return models
113108

114109
def find_app(self, app_label):
@@ -133,9 +128,8 @@ def get_apps(self):
133128
# Ensure the returned list is always in the same order (with new apps
134129
# added at the end). This avoids unstable ordering on the admin app
135130
# list page, for example.
136-
apps = [(v, k) for k, v in self.app_store.items()]
137-
apps.sort()
138-
return [elt[1] for elt in apps]
131+
return [app.models_module for app in self.app_instances\
132+
if app.models_module]
139133

140134
def get_app(self, app_label, emptyOK=False):
141135
"""
@@ -184,15 +178,17 @@ def get_models(self, app_mod=None, include_auto_created=False, include_deferred=
184178
pass
185179
self._populate()
186180
if app_mod:
187-
app_list = [self.app_models.get(app_mod.__name__.split('.')[-2], SortedDict())]
181+
app_label = app_mod.__name__.split('.')[-2]
182+
app = self.find_app(app_label)
183+
if app:
184+
app_list = [app]
188185
else:
189-
#app_list = self.app_models.itervalues()
190186
app_list = self.app_instances
191187
model_list = []
192188
for app in app_list:
193189
models = app.models
194190
model_list.extend(
195-
model for model in models#app.values()
191+
model for model in models
196192
if ((not model._deferred or include_deferred)
197193
and (not model._meta.auto_created or include_auto_created))
198194
)
@@ -226,7 +222,7 @@ def register_models(self, app_label, *models):
226222
self.app_instances.append(app)
227223
for model in models:
228224
# Store as 'name: model' pair in a dictionary
229-
# in the app_models dictionary
225+
# in the models list of the App instance
230226
model_name = model._meta.object_name.lower()
231227
model_dict = self.app_models.setdefault(app_label, SortedDict())
232228
if model_name in model_dict:

0 commit comments

Comments
 (0)
0