diff options
author | Adrian Holovaty <adrian@holovaty.com> | 2009-03-11 03:39:34 +0000 |
---|---|---|
committer | Adrian Holovaty <adrian@holovaty.com> | 2009-03-11 03:39:34 +0000 |
commit | 315145f7ca682f8361d956e985f533a7fb421cde (patch) | |
tree | 959f7bac4d8356e4b900227646eace9f7c05ab48 /django/db/backends/postgresql/client.py | |
parent | 7daf0b94070ab29419825156ec68bca813e3c09f (diff) | |
download | django-315145f7ca682f8361d956e985f533a7fb421cde.tar.gz |
Fixed #10459 -- Refactored the internals of database connection objects so that connections know their own settings and pass around settings as dictionaries instead of passing around the Django settings module itself. This will make it easier for multiple database support. Thanks to Alex Gaynor for the initial patch.
This is backwards-compatible but will likely break third-party database backends. Specific API changes are:
* BaseDatabaseWrapper.__init__() now takes a settings_dict instead of a settings module. It's called settings_dict to disambiguate, and for easy grepability. This should be a dictionary containing DATABASE_NAME, etc.
* BaseDatabaseWrapper has a settings_dict attribute instead of an options attribute. BaseDatabaseWrapper.options is now BaseDatabaseWrapper['DATABASE_OPTIONS']
* BaseDatabaseWrapper._cursor() no longer takes a settings argument.
* BaseDatabaseClient.__init__() now takes a connection argument (a DatabaseWrapper instance) instead of no arguments.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10026 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/backends/postgresql/client.py')
-rw-r--r-- | django/db/backends/postgresql/client.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/django/db/backends/postgresql/client.py b/django/db/backends/postgresql/client.py index 63f28a7b57..506372bfc4 100644 --- a/django/db/backends/postgresql/client.py +++ b/django/db/backends/postgresql/client.py @@ -1,19 +1,19 @@ from django.db.backends import BaseDatabaseClient -from django.conf import settings import os class DatabaseClient(BaseDatabaseClient): executable_name = 'psql' def runshell(self): + settings_dict = self.connection.settings_dict args = [self.executable_name] - if settings.DATABASE_USER: - args += ["-U", settings.DATABASE_USER] - if settings.DATABASE_PASSWORD: + if settings_dict['DATABASE_USER']: + args += ["-U", settings_dict['DATABASE_USER']] + if settings_dict['DATABASE_PASSWORD']: args += ["-W"] - if settings.DATABASE_HOST: - args.extend(["-h", settings.DATABASE_HOST]) - if settings.DATABASE_PORT: - args.extend(["-p", str(settings.DATABASE_PORT)]) - args += [settings.DATABASE_NAME] + if settings_dict['DATABASE_HOST']: + args.extend(["-h", settings_dict['DATABASE_HOST']]) + if settings_dict['DATABASE_PORT']: + args.extend(["-p", str(settings_dict['DATABASE_PORT'])]) + args += [settings_dict['DATABASE_NAME']] os.execvp(self.executable_name, args) |