Opened 5 years ago

Closed 3 years ago

Last modified 3 years ago

#14264 closed Bug (fixed)

settings.configure has undocumented differences from using a settings module

Reported by: carljm Owned by: gwilson
Component: Core (Other) Version: master
Severity: Normal Keywords:
Cc: metzen@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

Calling django.conf.settings.configure bypasses the Settings class in that module entirely (in favor of UserSettingsHolder), thereby bypassing all of Settings.init. This makes it subtly but occasionally critically different: globs in INSTALLED_APPS are not processed, the os.environ timezone is not set, and there is no friendly string-conversion-to-tuple for settings like TEMPLATE_DIRS.

Not setting os.environ timezone is documented and correct: settings.configure implies that you are in control of your environment and may be using Django as a piece of a larger system, Django should not go messing with the environment.

The other two differences are oversights and should be fixed.

Attachments (3)

14264.diff (11.4 KB) - added by gwilson 4 years ago.
14264.2.diff (13.7 KB) - added by gwilson 4 years ago.
14264.3.diff (1.6 KB) - added by metzen 3 years ago.

Download all attachments as: .zip

Change History (13)

comment:1 Changed 5 years ago by carljm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from settings.configure not equivalent to using a settings module to settings.configure has undocumented differences from using a settings module
  • Triage Stage changed from Unreviewed to Accepted

Correcting summary and marking Accepted per discussion with Malcolm at sprint.

comment:2 Changed 4 years ago by julien

  • Severity set to Normal
  • Type set to Bug

comment:3 Changed 4 years ago by gwilson

  • Easy pickings unset
  • Owner changed from nobody to gwilson
  • Status changed from new to assigned
  • UI/UX unset

Changed 4 years ago by gwilson

comment:4 Changed 4 years ago by gwilson

  • Has patch set

A patch that refactors the Settings classes a bit, gets rid of the need for a BaseSettings class, and makes it so that the UserSettingsHolder class uses the same code paths for some post-processing of settings.

Changed 4 years ago by gwilson

comment:5 Changed 4 years ago by jezdez

  • Patch needs improvement set

Please don't call the method initialize but load (or similar), the ambiguity to __init__ is odd. Other than that this looks good to me.

Changed 3 years ago by metzen

comment:6 Changed 3 years ago by metzen

Both the INSTALLED_APPS globs and string-to-tuple conversion have been deprecated, but calling configure() now also doesn't properly initialize the logging configuration from the settings LOGGING and LOGGING_CONFIG values. This can be fixed with a simple patch, which I've attached.

comment:7 Changed 3 years ago by metzen

  • Cc metzen@… added

comment:8 Changed 3 years ago by Claude Paroz <claude@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In 34162698cc7a3c75b1d1b2e18b481aa7e865dc98:

Fixed #14264 -- Ensured settings.configure configures logging

Thanks Matt McDonald for the patch.

comment:9 Changed 3 years ago by Claude Paroz <claude@…>

In e6bc0c5babe97af86679ef7fe4f5975eb86f532f:

[1.5.x] Fixed #14264 -- Ensured settings.configure configures logging

Thanks Matt McDonald for the patch.
Backport of 34162698c from master.

comment:10 Changed 3 years ago by claudep

#18316 was a duplicate

Note: See TracTickets for help on using tickets.
Back to Top