summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/db/models/loading.py32
1 files changed, 12 insertions, 20 deletions
diff --git a/django/db/models/loading.py b/django/db/models/loading.py
index 773050d624..d57780c578 100644
--- a/django/db/models/loading.py
+++ b/django/db/models/loading.py
@@ -14,37 +14,29 @@ import os
__all__ = ('get_apps', 'get_app', 'get_models', 'get_model', 'register_models',
'load_app', 'app_cache_ready')
+
class AppCache(object):
"""
A cache that stores installed applications and their models. Used to
provide reverse-relations and for app introspection (e.g. admin).
"""
- # Use the Borg pattern to share state between all instances. Details at
- # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66531.
- __shared_state = dict(
- # Keys of app_store are the model modules for each application.
- app_store = SortedDict(),
+ def __init__(self):
+ # Keys of app_store are the model modules for each application.
+ self.app_store = SortedDict()
# Mapping of installed app_labels to model modules for that app.
- app_labels = {},
-
+ self.app_labels = {}
# Mapping of app_labels to a dictionary of model names to model code.
# May contain apps that are not installed.
- app_models = SortedDict(),
-
+ self.app_models = SortedDict()
# Mapping of app_labels to errors raised when trying to import the app.
- app_errors = {},
-
+ self.app_errors = {}
# -- Everything below here is only used when populating the cache --
- loaded = False,
- handled = {},
- postponed = [],
- nesting_level = 0,
- _get_models_cache = {},
- )
-
- def __init__(self):
- self.__dict__ = self.__shared_state
+ self.loaded = False
+ self.handled = {}
+ self.postponed = []
+ self.nesting_level = 0
+ self._get_models_cache = {}
def _populate(self):
"""