Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[soc2009/multidb] Added backwards compatibility layer for contrib.gis…

…. Patch from Russell Keith-Magee.

git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/multidb@11868 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 808aa3b89de27edb670fa03077488580c34d529a 1 parent d5e883f
Alex Gaynor authored December 15, 2009
3  TODO
@@ -4,9 +4,6 @@ Django Multiple Database TODO List
4 4
 Required for v1.2
5 5
 ~~~~~~~~~~~~~~~~~
6 6
 
7  
- * Finalize the sql.Query internals
8  
-   * Clean up the use of db.backend.query_class()
9  
-   * Verify it still works with GeoDjango
10 7
  * Modify the admin interface to support multiple databases (doh).
11 8
 
12 9
 Optional for v1.2
24  django/db/__init__.py
@@ -36,12 +36,26 @@
36 36
 
37 37
 for database in settings.DATABASES.values():
38 38
     if database['ENGINE'] in ("postgresql", "postgresql_psycopg2", "sqlite3", "mysql", "oracle"):
39  
-        database['ENGINE'] = "django.db.backends.%s" % database['ENGINE']
40 39
         import warnings
41  
-        warnings.warn(
42  
-            "Short names for DATABASE_ENGINE are deprecated; prepend with 'django.db.backends.'",
43  
-            PendingDeprecationWarning
44  
-        )
  40
+        if 'django.contrib.gis' in settings.INSTALLED_APPS:
  41
+            warnings.warn(
  42
+                "django.contrib.gis is now implemented as a full database backend.\n"
  43
+                "Modify DATABASE_ENGINE to select a backend from 'django.contrib.gis.db.backends'",
  44
+                PendingDeprecationWarning
  45
+            )
  46
+            if database['ENGINE'] == 'postgresql_psycopg2':
  47
+                full_engine = 'django.contrib.gis.db.backends.postgis'
  48
+            elif database['ENGINE'] == 'sqlite3':
  49
+                full_engine = 'django.contrib.gis.db.backends.spatialite'
  50
+            else:
  51
+                full_engine = 'django.contrib.gis.db.backends.%s' % database['ENGINE']
  52
+        else:
  53
+            warnings.warn(
  54
+                "Short names for DATABASE_ENGINE are deprecated; prepend with 'django.db.backends.'",
  55
+                PendingDeprecationWarning
  56
+            )
  57
+            full_engine = "django.db.backends.%s" % database['ENGINE']
  58
+        database['ENGINE'] = full_engine
45 59
 
46 60
 connections = ConnectionHandler(settings.DATABASES)
47 61
 

0 notes on commit 808aa3b

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