Removed the _-prefix for populate().
Several parts of Django call get_apps() with a comment along this lines of "this has the side effect of calling _populate()". I fail to see how this is better than just calling populate()!
This commit is contained in:
parent
ebda5800ae
commit
d44de9b933
|
@ -60,11 +60,11 @@ class BaseAppCache(object):
|
|||
|
||||
def __init__(self):
|
||||
self.__dict__ = _initialize()
|
||||
# This stops _populate loading from INSTALLED_APPS and ignores the
|
||||
# This stops populate loading from INSTALLED_APPS and ignores the
|
||||
# only_installed arguments to get_model[s]
|
||||
self.loads_installed = False
|
||||
|
||||
def _populate(self):
|
||||
def populate(self):
|
||||
"""
|
||||
Fill in all the cache information. This method is threadsafe, in the
|
||||
sense that every caller will see the same state upon return, and if the
|
||||
|
@ -161,7 +161,7 @@ class BaseAppCache(object):
|
|||
If only_installed is True (default), only applications explicitly
|
||||
listed in INSTALLED_APPS are considered.
|
||||
"""
|
||||
self._populate()
|
||||
self.populate()
|
||||
for app_config in self.app_configs.values():
|
||||
if only_installed and not app_config.installed:
|
||||
continue
|
||||
|
@ -181,7 +181,7 @@ class BaseAppCache(object):
|
|||
If only_installed is True (default), only applications explicitly
|
||||
listed in INSTALLED_APPS are considered.
|
||||
"""
|
||||
self._populate()
|
||||
self.populate()
|
||||
app_config = self.app_configs.get(app_label)
|
||||
if app_config is None or (only_installed and not app_config.installed):
|
||||
raise LookupError("No app with label %r." % app_label)
|
||||
|
@ -246,7 +246,7 @@ class BaseAppCache(object):
|
|||
return model_list
|
||||
except KeyError:
|
||||
pass
|
||||
self._populate()
|
||||
self.populate()
|
||||
if app_mod:
|
||||
app_label = self._label_for(app_mod)
|
||||
try:
|
||||
|
@ -289,7 +289,7 @@ class BaseAppCache(object):
|
|||
if not self.loads_installed:
|
||||
only_installed = False
|
||||
if seed_cache:
|
||||
self._populate()
|
||||
self.populate()
|
||||
if only_installed:
|
||||
app_config = self.app_configs.get(app_label)
|
||||
if app_config is not None and not app_config.installed:
|
||||
|
@ -371,7 +371,7 @@ class BaseAppCache(object):
|
|||
"[a.path for a in get_app_configs()] supersedes get_app_paths().",
|
||||
PendingDeprecationWarning, stacklevel=2)
|
||||
|
||||
self._populate()
|
||||
self.populate()
|
||||
|
||||
app_paths = []
|
||||
for app in self.get_apps():
|
||||
|
|
|
@ -16,9 +16,9 @@ __all__ = ['BaseValidator', 'InlineValidator']
|
|||
|
||||
class BaseValidator(object):
|
||||
def __init__(self):
|
||||
# Before we can introspect models, they need to be fully loaded so that
|
||||
# inter-relations are set up correctly. We force that here.
|
||||
app_cache.get_apps()
|
||||
# Before we can introspect models, they need the app cache to be fully
|
||||
# loaded so that inter-relations are set up correctly.
|
||||
app_cache.populate()
|
||||
|
||||
def validate(self, cls, model):
|
||||
for m in dir(self):
|
||||
|
|
|
@ -137,10 +137,9 @@ class Deserializer(six.Iterator):
|
|||
self.stream = six.StringIO(stream_or_string)
|
||||
else:
|
||||
self.stream = stream_or_string
|
||||
# hack to make sure that the models have all been loaded before
|
||||
# deserialization starts (otherwise subclass calls to get_model()
|
||||
# and friends might fail...)
|
||||
app_cache.get_apps()
|
||||
# Make sure the app cache is loaded before deserialization starts
|
||||
# (otherwise subclass calls to get_model() and friends might fail...)
|
||||
app_cache.populate()
|
||||
|
||||
def __iter__(self):
|
||||
return self
|
||||
|
|
|
@ -88,7 +88,8 @@ def Deserializer(object_list, **options):
|
|||
db = options.pop('using', DEFAULT_DB_ALIAS)
|
||||
ignore = options.pop('ignorenonexistent', False)
|
||||
|
||||
app_cache.get_apps()
|
||||
app_cache.populate()
|
||||
|
||||
for d in object_list:
|
||||
# Look up the model and starting build a dict of data for it.
|
||||
Model = _get_model(d["model"])
|
||||
|
|
|
@ -30,6 +30,6 @@ def get_app_errors():
|
|||
try:
|
||||
return app_cache.app_errors
|
||||
except AttributeError:
|
||||
app_cache._populate()
|
||||
app_cache.populate()
|
||||
app_cache.app_errors = {}
|
||||
return app_cache.app_errors
|
||||
|
|
|
@ -128,7 +128,7 @@ def setup(verbosity, test_labels):
|
|||
# Load all the ALWAYS_INSTALLED_APPS.
|
||||
with warnings.catch_warnings():
|
||||
warnings.filterwarnings('ignore', 'django.contrib.comments is deprecated and will be removed before Django 1.8.', DeprecationWarning)
|
||||
app_cache.get_apps()
|
||||
app_cache.populate()
|
||||
|
||||
# Load all the test model apps.
|
||||
test_modules = get_test_modules()
|
||||
|
|
Loading…
Reference in New Issue