Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Removed legacy handing for `settings.DATABAS_*` and using short-form …

…references to the included database backends.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15959 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 9b3aaae255fad098e801e4813f646492a8a29e57 1 parent e57cc90
Alex Gaynor authored March 30, 2011
50  django/db/__init__.py
@@ -8,59 +8,9 @@
8 8
     'IntegrityError', 'DEFAULT_DB_ALIAS')
9 9
 
10 10
 
11  
-# For backwards compatibility - Port any old database settings over to
12  
-# the new values.
13  
-if not settings.DATABASES:
14  
-    if settings.DATABASE_ENGINE:
15  
-        import warnings
16  
-        warnings.warn(
17  
-            "settings.DATABASE_* is deprecated; use settings.DATABASES instead.",
18  
-            DeprecationWarning
19  
-        )
20  
-
21  
-    settings.DATABASES[DEFAULT_DB_ALIAS] = {
22  
-        'ENGINE': settings.DATABASE_ENGINE,
23  
-        'HOST': settings.DATABASE_HOST,
24  
-        'NAME': settings.DATABASE_NAME,
25  
-        'OPTIONS': settings.DATABASE_OPTIONS,
26  
-        'PASSWORD': settings.DATABASE_PASSWORD,
27  
-        'PORT': settings.DATABASE_PORT,
28  
-        'USER': settings.DATABASE_USER,
29  
-        'TEST_CHARSET': settings.TEST_DATABASE_CHARSET,
30  
-        'TEST_COLLATION': settings.TEST_DATABASE_COLLATION,
31  
-        'TEST_NAME': settings.TEST_DATABASE_NAME,
32  
-    }
33  
-
34 11
 if DEFAULT_DB_ALIAS not in settings.DATABASES:
35 12
     raise ImproperlyConfigured("You must define a '%s' database" % DEFAULT_DB_ALIAS)
36 13
 
37  
-for alias, database in settings.DATABASES.items():
38  
-    if 'ENGINE' not in database:
39  
-        raise ImproperlyConfigured("You must specify a 'ENGINE' for database '%s'" % alias)
40  
-    if database['ENGINE'] in ("postgresql", "postgresql_psycopg2", "sqlite3", "mysql", "oracle"):
41  
-        import warnings
42  
-        if 'django.contrib.gis' in settings.INSTALLED_APPS:
43  
-            warnings.warn(
44  
-                "django.contrib.gis is now implemented as a full database backend. "
45  
-                "Modify ENGINE in the %s database configuration to select "
46  
-                "a backend from 'django.contrib.gis.db.backends'" % alias,
47  
-                DeprecationWarning
48  
-            )
49  
-            if database['ENGINE'] == 'postgresql_psycopg2':
50  
-                full_engine = 'django.contrib.gis.db.backends.postgis'
51  
-            elif database['ENGINE'] == 'sqlite3':
52  
-                full_engine = 'django.contrib.gis.db.backends.spatialite'
53  
-            else:
54  
-                full_engine = 'django.contrib.gis.db.backends.%s' % database['ENGINE']
55  
-        else:
56  
-            warnings.warn(
57  
-                "Short names for ENGINE in database configurations are deprecated. "
58  
-                "Prepend %s.ENGINE with 'django.db.backends.'" % alias,
59  
-                DeprecationWarning
60  
-            )
61  
-            full_engine = "django.db.backends.%s" % database['ENGINE']
62  
-        database['ENGINE'] = full_engine
63  
-
64 14
 connections = ConnectionHandler(settings.DATABASES)
65 15
 
66 16
 router = ConnectionRouter(settings.DATABASE_ROUTERS)
60  django/db/utils.py
... ...
@@ -1,4 +1,3 @@
1  
-import inspect
2 1
 import os
3 2
 
4 3
 from django.conf import settings
@@ -19,38 +18,29 @@ class IntegrityError(DatabaseError):
19 18
 
20 19
 
21 20
 def load_backend(backend_name):
  21
+    # Look for a fully qualified database backend name
22 22
     try:
23  
-        module = import_module('.base', 'django.db.backends.%s' % backend_name)
24  
-        import warnings
25  
-        warnings.warn(
26  
-            "Short names for DATABASE_ENGINE are deprecated; prepend with 'django.db.backends.'",
27  
-            DeprecationWarning
28  
-        )
29  
-        return module
30  
-    except ImportError, e:
31  
-        # Look for a fully qualified database backend name
  23
+        return import_module('.base', backend_name)
  24
+    except ImportError, e_user:
  25
+        # The database backend wasn't found. Display a helpful error message
  26
+        # listing all possible (built-in) database backends.
  27
+        backend_dir = os.path.join(os.path.dirname(__file__), 'backends')
32 28
         try:
33  
-            return import_module('.base', backend_name)
34  
-        except ImportError, e_user:
35  
-            # The database backend wasn't found. Display a helpful error message
36  
-            # listing all possible (built-in) database backends.
37  
-            backend_dir = os.path.join(os.path.dirname(__file__), 'backends')
38  
-            try:
39  
-                available_backends = [f for f in os.listdir(backend_dir)
40  
-                        if os.path.isdir(os.path.join(backend_dir, f))
41  
-                        and not f.startswith('.')]
42  
-            except EnvironmentError:
43  
-                available_backends = []
44  
-            if backend_name.startswith('django.db.backends.'):
45  
-                backend_name = backend_name[19:] # See #15621.
46  
-            if backend_name not in available_backends:
47  
-                error_msg = ("%r isn't an available database backend. \n" +
48  
-                    "Try using django.db.backends.XXX, where XXX is one of:\n    %s\n" +
49  
-                    "Error was: %s") % \
50  
-                    (backend_name, ", ".join(map(repr, sorted(available_backends))), e_user)
51  
-                raise ImproperlyConfigured(error_msg)
52  
-            else:
53  
-                raise # If there's some other error, this must be an error in Django itself.
  29
+            available_backends = [f for f in os.listdir(backend_dir)
  30
+                    if os.path.isdir(os.path.join(backend_dir, f))
  31
+                    and not f.startswith('.')]
  32
+        except EnvironmentError:
  33
+            available_backends = []
  34
+        if backend_name.startswith('django.db.backends.'):
  35
+            backend_name = backend_name[19:] # See #15621.
  36
+        if backend_name not in available_backends:
  37
+            error_msg = ("%r isn't an available database backend. \n" +
  38
+                "Try using django.db.backends.XXX, where XXX is one of:\n    %s\n" +
  39
+                "Error was: %s") % \
  40
+                (backend_name, ", ".join(map(repr, sorted(available_backends))), e_user)
  41
+            raise ImproperlyConfigured(error_msg)
  42
+        else:
  43
+            raise # If there's some other error, this must be an error in Django itself.
54 44
 
55 45
 
56 46
 class ConnectionDoesNotExist(Exception):
@@ -76,13 +66,11 @@ def ensure_defaults(self, alias):
76 66
         if conn['ENGINE'] == 'django.db.backends.' or not conn['ENGINE']:
77 67
             conn['ENGINE'] = 'django.db.backends.dummy'
78 68
         conn.setdefault('OPTIONS', {})
79  
-        conn.setdefault('TEST_CHARSET', None)
80  
-        conn.setdefault('TEST_COLLATION', None)
81  
-        conn.setdefault('TEST_NAME', None)
82  
-        conn.setdefault('TEST_MIRROR', None)
83 69
         conn.setdefault('TIME_ZONE', settings.TIME_ZONE)
84  
-        for setting in ('NAME', 'USER', 'PASSWORD', 'HOST', 'PORT'):
  70
+        for setting in ['NAME', 'USER', 'PASSWORD', 'HOST', 'PORT']:
85 71
             conn.setdefault(setting, '')
  72
+        for setting in ['TEST_CHARSET', 'TEST_COLLATION', 'TEST_NAME', 'TEST_MIRROR']:
  73
+            conn.setdefault(setting, None)
86 74
 
87 75
     def __getitem__(self, alias):
88 76
         if alias in self._connections:

0 notes on commit 9b3aaae

Please sign in to comment.
Something went wrong with that request. Please try again.