Django

Code

Changeset 3668

Show
Ignore:
Timestamp:
08/27/06 15:45:32 (2 years ago)
Author:
jpellerin
Message:

[multi-db] Removed unused functions from django.core.management. Updated django.core.managment.get_sql_create to allow it to work without an active db connection.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/multiple-db-support/django/core/management.py

    r3667 r3668  
    5252def _is_valid_dir_name(s): 
    5353    return bool(re.search(r'^\w+$', s)) 
    54  
    55 def _get_installed_models(table_list): 
    56     "Gets a set of all models that are installed, given a list of existing tables" 
    57     from django.db import models 
    58     all_models = [] 
    59     for app in models.get_apps(): 
    60         for model in models.get_models(app): 
    61             all_models.append(model) 
    62     return set([m for m in all_models if m._meta.db_table in table_list]) 
    63  
    64 def _get_table_list(): 
    65     "Gets a list of all db tables that are physically installed." 
    66     from django.db import connection, get_introspection_module 
    67     cursor = connection.cursor() 
    68     return get_introspection_module().get_table_list(cursor) 
    6954 
    7055# If the foreign key points to an AutoField, a PositiveIntegerField or a 
     
    115100        # harmless, so we can be conservative). 
    116101        manager = model._default_manager 
    117         tables = manager.get_table_list() 
     102        try: 
     103            tables = manager.get_table_list() 
     104        except (KeyboardInterrupt, SystemExit): 
     105            raise 
     106        except: 
     107            # Something else went wrong -- maybe the database isn't 
     108            # running. But we can still generate sql, so use an empty 
     109            # table list. 
     110            tables = [] 
     111 
    118112        installed_models = [ model for model in 
    119113                             manager.get_installed_models(tables)