Ticket #5743: 5743.diff
File 5743.diff, 4.6 KB (added by , 17 years ago) |
---|
-
django/conf/__init__.py
10 10 import time # Needed for Windows 11 11 from django.conf import global_settings 12 12 13 class ConfigurationError(ImportError, EnvironmentError): 14 pass 15 13 16 ENVIRONMENT_VARIABLE = "DJANGO_SETTINGS_MODULE" 14 17 15 18 class LazySettings(object): … … 52 55 if not settings_module: # If it's set but is an empty string. 53 56 raise KeyError 54 57 except KeyError: 55 raise EnvironmentError, "Environment variable %s is undefined." % ENVIRONMENT_VARIABLE58 raise ConfigurationError, "Environment variable %s is undefined." % ENVIRONMENT_VARIABLE 56 59 57 60 self._target = Settings(settings_module) 58 61 … … 63 66 argument must support attribute access (__getattr__)). 64 67 """ 65 68 if self._target != None: 66 raise EnvironmentError, 'Settings already configured.'69 raise ConfigurationError, 'Settings already configured.' 67 70 holder = UserSettingsHolder(default_settings) 68 71 for name, value in options.items(): 69 72 setattr(holder, name, value) … … 81 84 82 85 try: 83 86 mod = __import__(self.SETTINGS_MODULE, {}, {}, ['']) 84 except ImportError, e:85 raise EnvironmentError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)87 except ConfigurationError, e: 88 raise ImportError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e) 86 89 87 90 # Settings that should be converted into tuples if they're mistakenly entered 88 91 # as strings. -
django/core/management/__init__.py
4 4 from imp import find_module 5 5 6 6 import django 7 from django.conf import ConfigurationError 7 8 from django.core.management.base import BaseCommand, CommandError, handle_default_options 8 9 9 10 # For backwards compatibility: get_version() used to be in this module. … … 84 85 try: 85 86 from django.conf import settings 86 87 apps = settings.INSTALLED_APPS 87 except (AttributeError, EnvironmentError):88 except (AttributeError, ConfigurationError): 88 89 apps = [] 89 90 90 91 for app_name in apps: … … 99 100 try: 100 101 from django.conf import settings 101 102 project_directory = setup_environ(__import__(settings.SETTINGS_MODULE)) 102 except (AttributeError, EnvironmentError, ImportError):103 except (AttributeError, ConfigurationError, ImportError): 103 104 project_directory = None 104 105 105 106 if project_directory: -
django/newforms/fields.py
16 16 except NameError: 17 17 from sets import Set as set 18 18 19 from django.conf import ConfigurationError 19 20 from django.utils.translation import ugettext_lazy as _ 20 21 from django.utils.encoding import StrAndUnicode, smart_unicode, smart_str 21 22 … … 415 416 try: 416 417 from django.conf import settings 417 418 URL_VALIDATOR_USER_AGENT = settings.URL_VALIDATOR_USER_AGENT 418 except (ImportError, EnvironmentError):419 except (ImportError, ConfigurationError): 419 420 # It's OK if Django settings aren't configured. 420 421 URL_VALIDATOR_USER_AGENT = 'Django (http://www.djangoproject.com/)' 421 422 -
docs/settings.txt
1129 1129 settings. 1130 1130 1131 1131 If you don't set ``DJANGO_SETTINGS_MODULE`` and don't call ``configure()``, 1132 Django will raise an `` EnvironmentError`` exception the first time a setting1133 is accessed.1132 Django will raise an ``django.conf.ConfigurationError`` exception the first 1133 time a setting is accessed. 1134 1134 1135 1135 If you set ``DJANGO_SETTINGS_MODULE``, access settings values somehow, *then* 1136 call ``configure()``, Django will raise an `` EnvironmentError`` saying settings1137 have already been configured.1136 call ``configure()``, Django will raise an ``django.conf.ConfigurationError`` 1137 saying settings have already been configured. 1138 1138 1139 1139 Also, it's an error to call ``configure()`` more than once, or to call 1140 1140 ``configure()`` after any setting has been accessed.