Ticket #904: django-env_w_sympathy4win.diff
File django-env_w_sympathy4win.diff, 2.5 KB (added by , 19 years ago) |
---|
-
utils/translation.py
117 117 118 118 globalpath = os.path.join(os.path.dirname(settings.__file__), 'locale') 119 119 120 parts = os.environ['DJANGO_SETTINGS_MODULE'].split('.')120 parts = settings.ROOT_URLCONF.split('.') 121 121 project = __import__(parts[0], {}, {}, []) 122 122 projectpath = os.path.join(os.path.dirname(project.__file__), 'locale') 123 123 -
conf/settings.py
8 8 9 9 import os 10 10 import sys 11 import os.path 12 import imp 11 13 from django.conf import global_settings 12 14 13 15 ENVIRONMENT_VARIABLE = "DJANGO_SETTINGS_MODULE" 16 SETTINGS_FILE = "settings.py" 14 17 15 18 # get a reference to this module (why isn't there a __module__ magic var?) 16 19 me = sys.modules[__name__] … … 20 23 if setting == setting.upper(): 21 24 setattr(me, setting, getattr(global_settings, setting)) 22 25 23 # try to load DJANGO_SETTINGS_MODULE 26 # try to load DJANGO_SETTINGS_MODULE if not found walk the filesystem upwards 27 # to find SETTINGS_FILE. If file is not found either raise EnvironmentError. 24 28 try: 25 29 me.SETTINGS_MODULE = os.environ[ENVIRONMENT_VARIABLE] 26 30 if not me.SETTINGS_MODULE: # If it's set but is an empty string. 27 31 raise KeyError 28 32 except KeyError: 29 raise EnvironmentError, "Environment variable %s is undefined." % ENVIRONMENT_VARIABLE 33 cwd = os.getcwdu() 34 35 while (cwd != '/' and cwd != 'C:\\'): 36 if os.path.exists(cwd + os.path.sep + SETTINGS_FILE): 37 mod = imp.load_source('settings', cwd + os.path.sep + SETTINGS_FILE) 38 break 39 else: 40 cwd = os.path.split(cwd)[0] 41 else: 42 raise EnvironmentError, "Environment variable %s is undefined." % \ 43 ENVIRONMENT_VARIABLE 44 else: 45 try: 46 mod = __import__(me.SETTINGS_MODULE, '', '', ['']) 47 except ImportError, e: 48 raise EnvironmentError, "Could not import %s '%s' (is it on sys.path?): %s" % \ 49 (ENVIRONMENT_VARIABLE, me.SETTINGS_MODULE, e) 30 50 31 try:32 mod = __import__(me.SETTINGS_MODULE, '', '', [''])33 except ImportError, e:34 raise EnvironmentError, "Could not import %s '%s' (is it on sys.path?): %s" % (ENVIRONMENT_VARIABLE, me.SETTINGS_MODULE, e)35 36 51 # Settings that should be converted into tuples if they're mistakenly entered 37 52 # as strings. 38 53 tuple_settings = ("INSTALLED_APPS", "TEMPLATE_DIRS")