Changeset 3668
- Timestamp:
- 08/27/06 15:45:32 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/multiple-db-support/django/core/management.py
r3667 r3668 52 52 def _is_valid_dir_name(s): 53 53 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 models58 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_module67 cursor = connection.cursor()68 return get_introspection_module().get_table_list(cursor)69 54 70 55 # If the foreign key points to an AutoField, a PositiveIntegerField or a … … 115 100 # harmless, so we can be conservative). 116 101 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 118 112 installed_models = [ model for model in 119 113 manager.get_installed_models(tables)
