mirror of
https://github.com/django/django.git
synced 2025-07-04 17:59:13 +00:00
[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
This commit is contained in:
parent
06f15e49b8
commit
6f4fc60126
@ -26,9 +26,6 @@ class AppCache(object):
|
|||||||
# List of App instances
|
# List of App instances
|
||||||
app_instances = [],
|
app_instances = [],
|
||||||
|
|
||||||
# Keys of app_store are the model modules for each application.
|
|
||||||
app_store = SortedDict(),
|
|
||||||
|
|
||||||
# Mapping of app_labels to a dictionary of model names to model code.
|
# Mapping of app_labels to a dictionary of model names to model code.
|
||||||
app_models = SortedDict(),
|
app_models = SortedDict(),
|
||||||
|
|
||||||
@ -104,11 +101,9 @@ class AppCache(object):
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
self.nesting_level -= 1
|
self.nesting_level -= 1
|
||||||
if models not in self.app_store:
|
app = self.find_app(app_name.split('.')[-1])
|
||||||
self.app_store[models] = len(self.app_store)
|
if app and models is not app.models_module:
|
||||||
app = self.find_app(app_name.split('.')[-1])
|
app.models_module = models
|
||||||
if app:
|
|
||||||
app.models_module = models
|
|
||||||
return models
|
return models
|
||||||
|
|
||||||
def find_app(self, app_label):
|
def find_app(self, app_label):
|
||||||
@ -133,9 +128,8 @@ class AppCache(object):
|
|||||||
# Ensure the returned list is always in the same order (with new apps
|
# Ensure the returned list is always in the same order (with new apps
|
||||||
# added at the end). This avoids unstable ordering on the admin app
|
# added at the end). This avoids unstable ordering on the admin app
|
||||||
# list page, for example.
|
# list page, for example.
|
||||||
apps = [(v, k) for k, v in self.app_store.items()]
|
return [app.models_module for app in self.app_instances\
|
||||||
apps.sort()
|
if app.models_module]
|
||||||
return [elt[1] for elt in apps]
|
|
||||||
|
|
||||||
def get_app(self, app_label, emptyOK=False):
|
def get_app(self, app_label, emptyOK=False):
|
||||||
"""
|
"""
|
||||||
@ -184,15 +178,17 @@ class AppCache(object):
|
|||||||
pass
|
pass
|
||||||
self._populate()
|
self._populate()
|
||||||
if app_mod:
|
if app_mod:
|
||||||
app_list = [self.app_models.get(app_mod.__name__.split('.')[-2], SortedDict())]
|
app_label = app_mod.__name__.split('.')[-2]
|
||||||
|
app = self.find_app(app_label)
|
||||||
|
if app:
|
||||||
|
app_list = [app]
|
||||||
else:
|
else:
|
||||||
#app_list = self.app_models.itervalues()
|
|
||||||
app_list = self.app_instances
|
app_list = self.app_instances
|
||||||
model_list = []
|
model_list = []
|
||||||
for app in app_list:
|
for app in app_list:
|
||||||
models = app.models
|
models = app.models
|
||||||
model_list.extend(
|
model_list.extend(
|
||||||
model for model in models#app.values()
|
model for model in models
|
||||||
if ((not model._deferred or include_deferred)
|
if ((not model._deferred or include_deferred)
|
||||||
and (not model._meta.auto_created or include_auto_created))
|
and (not model._meta.auto_created or include_auto_created))
|
||||||
)
|
)
|
||||||
@ -226,7 +222,7 @@ class AppCache(object):
|
|||||||
self.app_instances.append(app)
|
self.app_instances.append(app)
|
||||||
for model in models:
|
for model in models:
|
||||||
# Store as 'name: model' pair in a dictionary
|
# Store as 'name: model' pair in a dictionary
|
||||||
# in the app_models dictionary
|
# in the models list of the App instance
|
||||||
model_name = model._meta.object_name.lower()
|
model_name = model._meta.object_name.lower()
|
||||||
model_dict = self.app_models.setdefault(app_label, SortedDict())
|
model_dict = self.app_models.setdefault(app_label, SortedDict())
|
||||||
if model_name in model_dict:
|
if model_name in model_dict:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user