From 808aa3b89de27edb670fa03077488580c34d529a Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Tue, 15 Dec 2009 08:25:58 +0000 Subject: [PATCH] [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 --- TODO | 3 --- django/db/__init__.py | 24 +++++++++++++++++++----- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/TODO b/TODO index 4a0aad16cb..3c6b97be1c 100644 --- a/TODO +++ b/TODO @@ -4,9 +4,6 @@ Django Multiple Database TODO List Required for v1.2 ~~~~~~~~~~~~~~~~~ - * Finalize the sql.Query internals - * Clean up the use of db.backend.query_class() - * Verify it still works with GeoDjango * Modify the admin interface to support multiple databases (doh). Optional for v1.2 diff --git a/django/db/__init__.py b/django/db/__init__.py index 358b431457..d8f20ee278 100644 --- a/django/db/__init__.py +++ b/django/db/__init__.py @@ -36,12 +36,26 @@ if DEFAULT_DB_ALIAS not in settings.DATABASES: for database in settings.DATABASES.values(): if database['ENGINE'] in ("postgresql", "postgresql_psycopg2", "sqlite3", "mysql", "oracle"): - database['ENGINE'] = "django.db.backends.%s" % database['ENGINE'] import warnings - warnings.warn( - "Short names for DATABASE_ENGINE are deprecated; prepend with 'django.db.backends.'", - PendingDeprecationWarning - ) + if 'django.contrib.gis' in settings.INSTALLED_APPS: + warnings.warn( + "django.contrib.gis is now implemented as a full database backend.\n" + "Modify DATABASE_ENGINE to select a backend from 'django.contrib.gis.db.backends'", + PendingDeprecationWarning + ) + if database['ENGINE'] == 'postgresql_psycopg2': + full_engine = 'django.contrib.gis.db.backends.postgis' + elif database['ENGINE'] == 'sqlite3': + full_engine = 'django.contrib.gis.db.backends.spatialite' + else: + full_engine = 'django.contrib.gis.db.backends.%s' % database['ENGINE'] + else: + warnings.warn( + "Short names for DATABASE_ENGINE are deprecated; prepend with 'django.db.backends.'", + PendingDeprecationWarning + ) + full_engine = "django.db.backends.%s" % database['ENGINE'] + database['ENGINE'] = full_engine connections = ConnectionHandler(settings.DATABASES)