Ticket #14861: 0001-move-logging-setup-to-after-settings-_really_-is-ful.patch

File 0001-move-logging-setup-to-after-settings-_really_-is-ful.patch, 2.2 KB (added by Simon Percivall, 13 years ago)

fix circular imports.

  • django/conf/__init__.py

    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):  
    4040            raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
    4141
    4242        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)
    4353
    4454    def configure(self, default_settings=global_settings, **options):
    4555        """
    class Settings(BaseSettings):  
    128138            os.environ['TZ'] = self.TIME_ZONE
    129139            time.tzset()
    130140
    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 
    141141
    142142class UserSettingsHolder(BaseSettings):
    143143    """
Back to Top