Author: mtredinnick
Date: 2006-07-29 16:04:41 -0500 (Sat, 29 Jul 2006)
New Revision: 3490

Modified:
   django/trunk/django/db/models/base.py
   django/trunk/django/db/models/loading.py
Log:
Seed the global app cache in a call to db.models.get_model() except when we are
constructing a model class. Refs #2348.


Modified: django/trunk/django/db/models/base.py
===================================================================
--- django/trunk/django/db/models/base.py       2006-07-29 18:41:56 UTC (rev 
3489)
+++ django/trunk/django/db/models/base.py       2006-07-29 21:04:41 UTC (rev 
3490)
@@ -44,7 +44,7 @@
             new_class._meta.app_label = model_module.__name__.split('.')[-2]
 
         # Bail out early if we have already created this class.
-        m = get_model(new_class._meta.app_label, name)
+        m = get_model(new_class._meta.app_label, name, False)
         if m is not None:
             return m
 
@@ -68,7 +68,7 @@
         # the first class for this model to register with the framework. There
         # should only be one class for each model, so we must always return the
         # registered version.
-        return get_model(new_class._meta.app_label, name)
+        return get_model(new_class._meta.app_label, name, False)
 
 class Model(object):
     __metaclass__ = ModelBase

Modified: django/trunk/django/db/models/loading.py
===================================================================
--- django/trunk/django/db/models/loading.py    2006-07-29 18:41:56 UTC (rev 
3489)
+++ django/trunk/django/db/models/loading.py    2006-07-29 21:04:41 UTC (rev 
3490)
@@ -75,11 +75,15 @@
             model_list.extend(get_models(app_mod))
         return model_list
 
-def get_model(app_label, model_name):
+def get_model(app_label, model_name, seed_cache = True):
     """
-    Returns the model matching the given app_label and case-insensitive 
model_name.
+    Returns the model matching the given app_label and case-insensitive
+    model_name.
+
     Returns None if no model is found.
     """
+    if seed_cache:
+        get_apps()
     try:
         model_dict = _app_models[app_label]
     except KeyError:


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates
-~----------~----~----~----~------~----~------~--~---

Reply via email to