Code

Opened 2 years ago

Closed 2 years ago

#17895 closed Bug (fixed)

override_settings doesn't send the setting_changed signal when restoring the original value

Reported by: aaugustin Owned by: nobody
Component: Testing framework Version: master
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Django 1.4 introduces the override_settings context manager / decorator. When a setting is overridden, it fires the setting_changed signal. This signal allows to clean up or reset state that depends on a given setting, when that setting is changed.

However, in the current implementation, the signal isn't fired when the original value of the setting is restored.

I think setting_changed would be easier to use if it's fired whenever the value of a setting is "changed" in a broad sense, that is "overridden" or "reset".

While discussing this on IRC, it was suggested to add an extra argument, like state="pre" / "post", to distinguish between the two phases.

I'm marking this ticket as a release blocker because it would significantly change the behavior of setting_changed; we must make a decision before 1.4.

It's also a prerequisite for 17882-second-take.patch on #17882.

Patch w/ tests and docs attached.

Attachments (2)

17895.diff (3.4 KB) - added by aaugustin 2 years ago.
17895-more-docs-improved-api.diff (3.8 KB) - added by aaugustin 2 years ago.

Download all attachments as: .zip

Change History (4)

Changed 2 years ago by aaugustin

comment:1 Changed 2 years ago by claudep

  • Triage Stage changed from Unreviewed to Accepted

I'm not super-convinced of the state argument. Would be nice to have a use case for it, even hypothetical.

Changed 2 years ago by aaugustin

comment:2 Changed 2 years ago by aaugustin

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

In [17708]:

Fixed #17895 -- Made override_settings send the setting_changed signal both when a setting is overridden and when it's restored.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.