diff options
| author | Jason Pellerin <jpellerin@gmail.com> | 2006-08-27 20:45:32 +0000 |
|---|---|---|
| committer | Jason Pellerin <jpellerin@gmail.com> | 2006-08-27 20:45:32 +0000 |
| commit | 5a58772a1ee470e2890d3c716ce4918555100a55 (patch) | |
| tree | 3cdde962a2d04a7e59c0f0b4f0389c51ac08a9e8 | |
| parent | be589f70345b6f50349e705195bcb0a007335e60 (diff) | |
[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.
git-svn-id: http://code.djangoproject.com/svn/django/branches/multiple-db-support@3668 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/core/management.py | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/django/core/management.py b/django/core/management.py index 6f27c71ab5..028b4d89a5 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -52,21 +52,6 @@ if sys.platform == 'win32' or sys.platform == 'Pocket PC' or not sys.stdout.isat def _is_valid_dir_name(s): return bool(re.search(r'^\w+$', s)) -def _get_installed_models(table_list): - "Gets a set of all models that are installed, given a list of existing tables" - from django.db import models - all_models = [] - for app in models.get_apps(): - for model in models.get_models(app): - all_models.append(model) - return set([m for m in all_models if m._meta.db_table in table_list]) - -def _get_table_list(): - "Gets a list of all db tables that are physically installed." - from django.db import connection, get_introspection_module - cursor = connection.cursor() - return get_introspection_module().get_table_list(cursor) - # If the foreign key points to an AutoField, a PositiveIntegerField or a # PositiveSmallIntegerField, the foreign key should be an IntegerField, not the # referred field type. Otherwise, the foreign key should be the same type of @@ -114,7 +99,16 @@ def get_sql_create(app): # not generate invalid SQL (leaving models out of known_models is # harmless, so we can be conservative). manager = model._default_manager - tables = manager.get_table_list() + try: + tables = manager.get_table_list() + except (KeyboardInterrupt, SystemExit): + raise + except: + # Something else went wrong -- maybe the database isn't + # running. But we can still generate sql, so use an empty + # table list. + tables = [] + installed_models = [ model for model in manager.get_installed_models(tables) if model not in app_models ] |
