Opened 12 years ago
Closed 12 years ago
#21833 closed Bug (fixed)
Use of new Settings.is_overridden() method breaks if settings.configure() is used
| Reported by: | Carl Meyer | Owned by: | nobody |
|---|---|---|---|
| Component: | Core (Other) | Version: | dev |
| Severity: | Release blocker | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
There are two ways to set up Django's settings; one is by passing a settings module to the Settings class, and the other is to call django.conf.settings.configure() with keyword arguments.
In d818e0c9b2b88276cc499974f9eee893170bf0a8 (the new checks framework) a new is_overridden method was added to Settings, and in the "check_1_6_compatibility" check, it is called on django.conf.settings. But if settings.configure() was used, django.conf.settings is not wrapping a Settings instance, it is wrapping a UserSettingsHolder instance. And thus the "check_1_6_compatibility" check dies with "AttributeError: 'module' object has no attribute 'is_overridden'".
Change History (4)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
First thought at a fix - either:
1) Add a try/except on the attempt to access the is_overridden property in UserSettingsHolder
2) Add an is_overridden method to global_settings.
I'd prefer (1) so we can keep global_setings clean, but I'm open to other suggestions.
comment:3 by , 12 years ago
Here's my proposed fix: https://github.com/django/django/pull/2188
In addition to fixing this bug and adding tests for is_overridden(), it also changes the semantics of UserSettingsHolder.is_overridden, but I don't think the previous semantics made sense: they ignored any setting that was explicitly set on the UserSettingsHolder, and they considered deletion of a setting to not be an override.
comment:4 by , 12 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Sorry, my description of the problem was incomplete.
UserSettingsHolderdoes have an implementation ofis_overridden(); the problem is that it tries to callself.default_settings.is_overridden(), and ifsettings.configure()was used,self.default_settingsis simply the module objectdjango.conf.global_settings, which obviously has nois_overriddenmethod. Thus the error.