Django

Code

Changeset 3490

Show
Ignore:
Timestamp:
07/29/06 16:04:41 (2 years ago)
Author:
mtredinnick
Message:

Seed the global app cache in a call to db.models.get_model() except when we are
constructing a model class. Refs #2348.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/db/models/base.py

    r3414 r3490  
    4545 
    4646        # Bail out early if we have already created this class. 
    47         m = get_model(new_class._meta.app_label, name
     47        m = get_model(new_class._meta.app_label, name, False
    4848        if m is not None: 
    4949            return m 
     
    6969        # should only be one class for each model, so we must always return the 
    7070        # registered version. 
    71         return get_model(new_class._meta.app_label, name
     71        return get_model(new_class._meta.app_label, name, False
    7272 
    7373class Model(object): 
  • django/trunk/django/db/models/loading.py

    r3243 r3490  
    7676        return model_list 
    7777 
    78 def get_model(app_label, model_name): 
     78def get_model(app_label, model_name, seed_cache = True): 
    7979    """ 
    80     Returns the model matching the given app_label and case-insensitive model_name. 
     80    Returns the model matching the given app_label and case-insensitive 
     81    model_name. 
     82 
    8183    Returns None if no model is found. 
    8284    """ 
     85    if seed_cache: 
     86        get_apps() 
    8387    try: 
    8488        model_dict = _app_models[app_label]