Opened 8 years ago

Closed 7 years ago

Last modified 5 years ago

#10130 closed (fixed)

Support setting deletion

Reported by: Joost Cassee Owned by: Joost Cassee
Component: Core (Other) Version: master
Severity: Keywords: settings
Cc: Ben Spaulding Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The LazySettings class supports setting and getting options, but not deleting them. Apart from the obvious symmetry, the very useful TestSettingsManager class from this snippet (which changes settings temporarily for tests) requires it.

The attached patch adds a __delattr__ method. Please consider applying it.

Attachments (3)

10130-r9791.diff (807 bytes) - added by Joost Cassee 8 years ago.
10130-r10407.diff (1.8 KB) - added by Joost Cassee 8 years ago.
10130-r11594.diff (1.6 KB) - added by Joost Cassee 7 years ago.
Remember to also add init.py and models.py to test directory.

Download all attachments as: .zip

Change History (17)

Changed 8 years ago by Joost Cassee

Attachment: 10130-r9791.diff added

comment:1 Changed 8 years ago by dc

You shouldn't alter settings in your applications at runtime.

http://docs.djangoproject.com/en/dev/topics/settings/#altering-settings-at-runtime

comment:2 in reply to:  1 Changed 8 years ago by Joost Cassee

Replying to dc:

You shouldn't alter settings in your applications at runtime.

I agree -- in theory. In practice I have an application of which the behaviour is dependent on settings, that I want to test.

comment:3 Changed 8 years ago by Jacob

milestone: 1.1
Triage Stage: UnreviewedAccepted

comment:4 Changed 8 years ago by Eric Holscher

Needs tests: set

Need to provide tests.

comment:5 Changed 8 years ago by Jacob

milestone: 1.11.2

comment:6 Changed 8 years ago by Joost Cassee

Needs tests: unset

Apparently a recent change broke the attached patch. The new one includes a trivial patch.

Changed 8 years ago by Joost Cassee

Attachment: 10130-r10407.diff added

comment:7 Changed 7 years ago by Chris Beaven

Patch needs improvement: set

Should test the '_wrapped' special case too - and I'd suggest that it should be raising AttributeError.

Changed 7 years ago by Joost Cassee

Attachment: 10130-r11594.diff added

Remember to also add init.py and models.py to test directory.

comment:8 Changed 7 years ago by Joost Cassee

Needs tests: set
Patch needs improvement: unset

Updated patch following SmileyChris' suggestions.

comment:9 Changed 7 years ago by Joost Cassee

Needs tests: unset
Owner: changed from nobody to Joost Cassee

comment:10 Changed 7 years ago by Chris Beaven

Triage Stage: AcceptedReady for checkin

comment:11 Changed 7 years ago by Ben Spaulding

Cc: Ben Spaulding added

comment:12 Changed 7 years ago by Jacob

Resolution: fixed
Status: newclosed

(In [11824]) FIxed #10130: you may now delete attributes on settings. Thanks, jcassee.

comment:13 Changed 7 years ago by Jacob

(In [11825]) [1.1.X] Fixed #10130: you may now delete attributes on settings. Thanks, jcassee.

Backport of r11824.

comment:14 Changed 5 years ago by Jacob

milestone: 1.2

Milestone 1.2 deleted

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