Ticket #952: corrected.diff
File corrected.diff, 5.8 KB (added by , 19 years ago) |
---|
-
django/conf/project_template/settings.py
15 15 DATABASE_PASSWORD = '' # Not used with sqlite3. 16 16 DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. 17 17 DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. 18 DATABASE_CLIENT_CHARSET = '' # Set to empty string to guess from DEFAULT_CHARSET. Not used with sqlite3. 18 19 19 20 # Local time zone for this installation. All choices can be found here: 20 21 # http://www.postgresql.org/docs/current/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE -
django/conf/global_settings.py
78 78 DATABASE_PASSWORD = '' # Not used with sqlite3. 79 79 DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. 80 80 DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. 81 DATABASE_CLIENT_CHARSET = '' # Set to empty string to guess from DEFAULT_CHARSET. Not used with sqlite3. 81 82 82 83 # Host for sending e-mail. 83 84 EMAIL_HOST = 'localhost' -
django/core/db/backends/postgresql.py
13 13 def __init__(self): 14 14 self.connection = None 15 15 self.queries = [] 16 self.charset_mappings = { 17 'utf-8':'UNICODE', 18 'windows-1251':'WINDOWS1251', 19 'windows-1250':'WINDOWS1250', 20 'shift-jis':'SJIS', 21 'koi8-r':'KOI8', 22 'koi8-u':'KOI8', 23 } 16 24 17 25 def cursor(self): 18 from django.conf.settings import DATABASE_USER, DATABASE_NAME, DATABASE_HOST, DATABASE_PORT, DATABASE_PASSWORD, DEBUG, TIME_ZONE 26 from django.conf.settings import DEFAULT_CHARSET, DATABASE_USER, DATABASE_NAME, DATABASE_HOST, \ 27 DATABASE_PORT, DATABASE_PASSWORD, DATABASE_CLIENT_CHARSET, DEBUG, TIME_ZONE 19 28 if self.connection is None: 20 29 if DATABASE_NAME == '': 21 30 from django.core.exceptions import ImproperlyConfigured … … 33 42 self.connection.set_isolation_level(1) # make transactions transparent to all cursors 34 43 cursor = self.connection.cursor() 35 44 cursor.execute("SET TIME ZONE %s", [TIME_ZONE]) 45 46 try: 47 charset = self.charset_mappings[DEFAULT_CHARSET.lower()] 48 except KeyError: 49 if (not DATABASE_CLIENT_CHARSET): 50 from django.core.exceptions import ImproperlyConfigured 51 raise ImproperlyConfigured, 'You need to specify DATABASE_CLIENT_CHARSET in your Django settings \ 52 file because Django cannot determine it automatically. You should set it to the name \ 53 that PostgreSQL uses for the character set "'+DEFAULT_CHARSET+'"' 54 else: 55 charset = DATABASE_CLIENT_CHARSET 56 57 self.connection.cursor().execute("SET CLIENT_ENCODING TO "+charset) 58 36 59 if DEBUG: 37 60 return base.CursorDebugWrapper(cursor, self) 38 61 return cursor -
django/core/db/backends/mysql.py
51 51 def __init__(self): 52 52 self.connection = None 53 53 self.queries = [] 54 self.charset_mappings = { 55 'utf-8':'utf8', 56 'windows-1251':'cp1251', 57 'windows-1250':'cp1250', 58 'shift-jis':'sjis', 59 'utf-16':'ucs2', 60 'koi8-r':'koi8r', 61 'koi8-u':'koi8u', 62 } 54 63 55 64 def cursor(self): 56 from django.conf.settings import DATABASE_USER, DATABASE_NAME, DATABASE_HOST, DATABASE_PORT, DATABASE_PASSWORD, DEBUG 65 from django.conf.settings import DEFAULT_CHARSET, DATABASE_USER, DATABASE_NAME, DATABASE_HOST, \ 66 DATABASE_PORT, DATABASE_PASSWORD, DATABASE_CLIENT_CHARSET, DEBUG 67 68 # additionally import charset-related settings that might not be present 69 from django.conf.settings import DEFAULT_CHARSET 70 57 71 if self.connection is None: 58 72 kwargs = { 59 73 'user': DATABASE_USER, … … 65 79 if DATABASE_PORT: 66 80 kwargs['port'] = DATABASE_PORT 67 81 self.connection = Database.connect(**kwargs) 82 83 try: 84 charset = self.charset_mappings[DEFAULT_CHARSET.lower()] 85 except KeyError: 86 if (not DATABASE_CLIENT_CHARSET): 87 from django.core.exceptions import ImproperlyConfigured 88 raise ImproperlyConfigured, 'You need to specify DATABASE_CLIENT_CHARSET in your Django settings \ 89 file because Django cannot determine it automatically. You should set it to the name \ 90 that MySQL uses for the character set "'+DEFAULT_CHARSET+'"' 91 else: 92 charset = DATABASE_CLIENT_CHARSET 93 try: 94 self.connection.cursor().execute("SET NAMES "+charset) 95 except Database.OperationalError: # this is MySQL older than 4.1 96 pass 97 68 98 if DEBUG: 69 99 return base.CursorDebugWrapper(MysqlDebugWrapper(self.connection.cursor()), self) 70 100 return self.connection.cursor()