1
0
mirror of https://github.com/django/django.git synced 2025-07-05 02:09:13 +00:00

[multi-db] Backed out settings access through conf.settings, which was based on an incorrect understanding of settings implementation.

git-svn-id: http://code.djangoproject.com/svn/django/branches/multiple-db-support@3430 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jason Pellerin 2006-07-23 04:05:30 +00:00
parent 94ccedf364
commit 14f8c83827

View File

@ -1,4 +1,4 @@
from django import conf from django.conf import settings, UserSettingsHolder
from django.core import signals from django.core import signals
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
from django.dispatch import dispatcher from django.dispatch import dispatcher
@ -19,8 +19,8 @@ _default = object()
_local = local() _local = local()
if not conf.settings.DATABASE_ENGINE: if not settings.DATABASE_ENGINE:
conf.settings.DATABASE_ENGINE = 'dummy' settings.DATABASE_ENGINE = 'dummy'
def connect(settings): def connect(settings):
@ -49,7 +49,7 @@ class ConnectionInfo(object):
""" """
def __init__(self, settings=None): def __init__(self, settings=None):
if settings is None: if settings is None:
settings = conf.settings from django.conf import settings
self.settings = settings self.settings = settings
self.backend = self.load_backend() self.backend = self.load_backend()
self.connection = self.backend.DatabaseWrapper(settings) self.connection = self.backend.DatabaseWrapper(settings)
@ -144,7 +144,6 @@ class LazyConnectionManager(object):
connection (a singleton defined in django.db), then the default connection (a singleton defined in django.db), then the default
connection is returned. connection is returned.
""" """
settings = conf.settings
try: try:
cnx = self.local.connections cnx = self.local.connections
except AttributeError: except AttributeError:
@ -153,7 +152,7 @@ class LazyConnectionManager(object):
if name in cnx: if name in cnx:
cnx[name].close() cnx[name].close()
if name is _default: if name is _default:
cnx[name] = connect(conf.settings) cnx[name] = connect(settings)
return cnx[name] return cnx[name]
try: try:
info = settings.OTHER_DATABASES[name] info = settings.OTHER_DATABASES[name]
@ -167,7 +166,7 @@ class LazyConnectionManager(object):
# In settings it's a dict, but connect() needs an object: # In settings it's a dict, but connect() needs an object:
# pass global settings so that the default connection settings # pass global settings so that the default connection settings
# can be defaults for the named connections. # can be defaults for the named connections.
database = conf.UserSettingsHolder(settings) database = UserSettingsHolder(settings)
for k, v in info.items(): for k, v in info.items():
setattr(database, k, v) setattr(database, k, v)
cnx[name] = connect(database) cnx[name] = connect(database)
@ -181,7 +180,6 @@ def model_connection_name(klass):
"""Get the connection name that a model is configured to use, with the """Get the connection name that a model is configured to use, with the
current settings. current settings.
""" """
settings = conf.settings
app = klass._meta.app_label app = klass._meta.app_label
model = klass.__name__ model = klass.__name__
app_model = "%s.%s" % (app, model) app_model = "%s.%s" % (app, model)