Opened 14 years ago

Closed 11 years ago

Last modified 11 years ago

#14264 closed Bug (fixed)

settings.configure has undocumented differences from using a settings module

Reported by: Carl Meyer Owned by: Gary Wilson
Component: Core (Other) Version: dev
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 Gary Wilson 13 years ago.
14264.2.diff (13.7 KB ) - added by Gary Wilson 13 years ago.
14264.3.diff (1.6 KB ) - added by Matt McDonald 11 years ago.

Download all attachments as: .zip

Change History (13)

comment:1 by Carl Meyer, 14 years ago

Summary: settings.configure not equivalent to using a settings modulesettings.configure has undocumented differences from using a settings module
Triage Stage: UnreviewedAccepted

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

comment:2 by Julien Phalip, 13 years ago

Severity: Normal
Type: Bug

comment:3 by Gary Wilson, 13 years ago

Easy pickings: unset
Owner: changed from nobody to Gary Wilson
Status: newassigned
UI/UX: unset

by Gary Wilson, 13 years ago

Attachment: 14264.diff added

comment:4 by Gary Wilson, 13 years ago

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.

by Gary Wilson, 13 years ago

Attachment: 14264.2.diff added

comment:5 by Jannis Leidel, 13 years ago

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.

by Matt McDonald, 11 years ago

Attachment: 14264.3.diff added

comment:6 by Matt McDonald, 11 years ago

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 by Matt McDonald, 11 years ago

Cc: metzen@… added

comment:8 by Claude Paroz <claude@…>, 11 years ago

Resolution: fixed
Status: assignedclosed

In 34162698cc7a3c75b1d1b2e18b481aa7e865dc98:

Fixed #14264 -- Ensured settings.configure configures logging

Thanks Matt McDonald for the patch.

comment:9 by Claude Paroz <claude@…>, 11 years ago

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 by Claude Paroz, 11 years ago

#18316 was a duplicate

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