mirror of
https://github.com/django/django.git
synced 2025-07-05 02:09:13 +00:00
[soc2009/multidb] Several optimizations and cleanups. Patch from Russell Keith-Magee.
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/multidb@11765 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
f2604c331d
commit
ba0d00ddbb
@ -31,10 +31,10 @@ class Command(BaseCommand):
|
|||||||
exclude = options.get('exclude',[])
|
exclude = options.get('exclude',[])
|
||||||
show_traceback = options.get('traceback', False)
|
show_traceback = options.get('traceback', False)
|
||||||
|
|
||||||
excluded_apps = [get_app(app_label) for app_label in exclude]
|
excluded_apps = set(get_app(app_label) for app_label in exclude)
|
||||||
|
|
||||||
if len(app_labels) == 0:
|
if len(app_labels) == 0:
|
||||||
app_list = SortedDict([(app, None) for app in get_apps() if app not in excluded_apps])
|
app_list = SortedDict((app, None) for app in get_apps() if app not in excluded_apps)
|
||||||
else:
|
else:
|
||||||
app_list = SortedDict()
|
app_list = SortedDict()
|
||||||
for label in app_labels:
|
for label in app_labels:
|
||||||
|
@ -59,11 +59,11 @@ class Command(NoArgsCommand):
|
|||||||
created_models = set()
|
created_models = set()
|
||||||
pending_references = {}
|
pending_references = {}
|
||||||
|
|
||||||
excluded_apps = [models.get_app(app_label) for app_label in exclude]
|
excluded_apps = set(models.get_app(app_label) for app_label in exclude)
|
||||||
app_list = [app for app in models.get_apps() if app not in excluded_apps]
|
included_apps = set(app for app in models.get_apps() if app not in excluded_apps)
|
||||||
|
|
||||||
# Create the tables for each model
|
# Create the tables for each model
|
||||||
for app in app_list:
|
for app in included_apps:
|
||||||
app_name = app.__name__.split('.')[-2]
|
app_name = app.__name__.split('.')[-2]
|
||||||
model_list = models.get_models(app, include_auto_created=True)
|
model_list = models.get_models(app, include_auto_created=True)
|
||||||
for model in model_list:
|
for model in model_list:
|
||||||
@ -101,7 +101,7 @@ class Command(NoArgsCommand):
|
|||||||
|
|
||||||
# Install custom SQL for the app (but only if this
|
# Install custom SQL for the app (but only if this
|
||||||
# is a model we've just created)
|
# is a model we've just created)
|
||||||
for app in app_list:
|
for app in included_apps:
|
||||||
app_name = app.__name__.split('.')[-2]
|
app_name = app.__name__.split('.')[-2]
|
||||||
for model in models.get_models(app):
|
for model in models.get_models(app):
|
||||||
if model in created_models:
|
if model in created_models:
|
||||||
@ -126,7 +126,7 @@ class Command(NoArgsCommand):
|
|||||||
print "No custom SQL for %s.%s model" % (app_name, model._meta.object_name)
|
print "No custom SQL for %s.%s model" % (app_name, model._meta.object_name)
|
||||||
|
|
||||||
# Install SQL indicies for all newly created models
|
# Install SQL indicies for all newly created models
|
||||||
for app in app_list:
|
for app in included_apps:
|
||||||
app_name = app.__name__.split('.')[-2]
|
app_name = app.__name__.split('.')[-2]
|
||||||
for model in models.get_models(app):
|
for model in models.get_models(app):
|
||||||
if model in created_models:
|
if model in created_models:
|
||||||
|
@ -16,6 +16,7 @@ except ImportError:
|
|||||||
# Python 2.3 fallback
|
# Python 2.3 fallback
|
||||||
from django.utils import _decimal as decimal
|
from django.utils import _decimal as decimal
|
||||||
|
|
||||||
|
from django.db import DEFAULT_DB_ALIAS
|
||||||
from django.db.backends import util
|
from django.db.backends import util
|
||||||
from django.utils import datetime_safe
|
from django.utils import datetime_safe
|
||||||
from django.utils.importlib import import_module
|
from django.utils.importlib import import_module
|
||||||
@ -26,7 +27,7 @@ class BaseDatabaseWrapper(local):
|
|||||||
"""
|
"""
|
||||||
ops = None
|
ops = None
|
||||||
|
|
||||||
def __init__(self, settings_dict, alias='default'):
|
def __init__(self, settings_dict, alias=DEFAULT_DB_ALIAS):
|
||||||
# `settings_dict` should be a dictionary containing keys such as
|
# `settings_dict` should be a dictionary containing keys such as
|
||||||
# DATABASE_NAME, DATABASE_USER, etc. It's called `settings_dict`
|
# DATABASE_NAME, DATABASE_USER, etc. It's called `settings_dict`
|
||||||
# instead of `settings` to disambiguate it from Django settings
|
# instead of `settings` to disambiguate it from Django settings
|
||||||
|
Loading…
x
Reference in New Issue
Block a user