From db12df1d84623c7730b4a720c3102cdcfd5f4878 Mon Sep 17 00:00:00 2001
From: Simon Percivall <simon.percivall@trioptima.com>
Date: Thu, 12 Jan 2012 18:14:36 +0100
Subject: [PATCH] move logging setup to after settings _really_ is fully
configured, otherwise attempts to reference settings from
within LOGGING causes infinite recursion.
---
django/conf/__init__.py | 20 ++++++++++----------
1 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/django/conf/__init__.py b/django/conf/__init__.py
index f2012a6..eec5ed9 100644
a
|
b
|
class LazySettings(LazyObject):
|
40 | 40 | raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE) |
41 | 41 | |
42 | 42 | self._wrapped = Settings(settings_module) |
| 43 | |
| 44 | # Settings are configured, so we can set up the logger if required |
| 45 | if self._wrapped.LOGGING_CONFIG: |
| 46 | # First find the logging configuration function ... |
| 47 | logging_config_path, logging_config_func_name = self._wrapped.LOGGING_CONFIG.rsplit('.', 1) |
| 48 | logging_config_module = importlib.import_module(logging_config_path) |
| 49 | logging_config_func = getattr(logging_config_module, logging_config_func_name) |
| 50 | |
| 51 | # ... then invoke it with the logging settings |
| 52 | logging_config_func(self._wrapped.LOGGING) |
43 | 53 | |
44 | 54 | def configure(self, default_settings=global_settings, **options): |
45 | 55 | """ |
… |
… |
class Settings(BaseSettings):
|
128 | 138 | os.environ['TZ'] = self.TIME_ZONE |
129 | 139 | time.tzset() |
130 | 140 | |
131 | | # Settings are configured, so we can set up the logger if required |
132 | | if self.LOGGING_CONFIG: |
133 | | # First find the logging configuration function ... |
134 | | logging_config_path, logging_config_func_name = self.LOGGING_CONFIG.rsplit('.', 1) |
135 | | logging_config_module = importlib.import_module(logging_config_path) |
136 | | logging_config_func = getattr(logging_config_module, logging_config_func_name) |
137 | | |
138 | | # ... then invoke it with the logging settings |
139 | | logging_config_func(self.LOGGING) |
140 | | |
141 | 141 | |
142 | 142 | class UserSettingsHolder(BaseSettings): |
143 | 143 | """ |