Kaydet (Commit) 439b364e authored tarafından Aymeric Augustin's avatar Aymeric Augustin

Added an _-prefix to pending lookups because it's transient.

üst 86804ab0
...@@ -43,9 +43,6 @@ class AppCache(object): ...@@ -43,9 +43,6 @@ class AppCache(object):
# Mapping of labels to AppConfig instances for installed apps. # Mapping of labels to AppConfig instances for installed apps.
self.app_configs = OrderedDict() self.app_configs = OrderedDict()
# Pending lookups for lazy relations
self.pending_lookups = {}
# Set of app names. Allows restricting the set of installed apps. # Set of app names. Allows restricting the set of installed apps.
# Used by TransactionTestCase.available_apps for performance reasons. # Used by TransactionTestCase.available_apps for performance reasons.
self.available_apps = None self.available_apps = None
...@@ -54,6 +51,9 @@ class AppCache(object): ...@@ -54,6 +51,9 @@ class AppCache(object):
self._apps_loaded = not self.master self._apps_loaded = not self.master
self._models_loaded = not self.master self._models_loaded = not self.master
# Pending lookups for lazy relations.
self._pending_lookups = {}
# Cache for get_models. # Cache for get_models.
self._get_models_cache = {} self._get_models_cache = {}
......
...@@ -74,7 +74,7 @@ def add_lazy_relation(cls, field, relation, operation): ...@@ -74,7 +74,7 @@ def add_lazy_relation(cls, field, relation, operation):
else: else:
key = (app_label, model_name) key = (app_label, model_name)
value = (cls, field, operation) value = (cls, field, operation)
cls._meta.app_cache.pending_lookups.setdefault(key, []).append(value) cls._meta.app_cache._pending_lookups.setdefault(key, []).append(value)
def do_pending_lookups(sender, **kwargs): def do_pending_lookups(sender, **kwargs):
...@@ -82,7 +82,7 @@ def do_pending_lookups(sender, **kwargs): ...@@ -82,7 +82,7 @@ def do_pending_lookups(sender, **kwargs):
Handle any pending relations to the sending model. Sent from class_prepared. Handle any pending relations to the sending model. Sent from class_prepared.
""" """
key = (sender._meta.app_label, sender.__name__) key = (sender._meta.app_label, sender.__name__)
for cls, field, operation in sender._meta.app_cache.pending_lookups.pop(key, []): for cls, field, operation in sender._meta.app_cache._pending_lookups.pop(key, []):
operation(field, sender, cls) operation(field, sender, cls)
signals.class_prepared.connect(do_pending_lookups) signals.class_prepared.connect(do_pending_lookups)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment