Opened 7 years ago

Closed 6 years ago

Last modified 4 years ago

#10130 closed (fixed)

Support setting deletion

Reported by: jcassee Owned by: jcassee
Component: Core (Other) Version: master
Severity: Keywords: settings
Cc: benspaulding 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 jcassee 7 years ago.
10130-r10407.diff (1.8 KB) - added by jcassee 6 years ago.
10130-r11594.diff (1.6 KB) - added by jcassee 6 years ago.
Remember to also add init.py and models.py to test directory.

Download all attachments as: .zip

Change History (17)

Changed 7 years ago by jcassee

comment:1 follow-up: Changed 7 years ago by dc

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 7 years ago by jcassee

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 7 years ago by jacob

  • milestone set to 1.1
  • Triage Stage changed from Unreviewed to Accepted

comment:4 Changed 6 years ago by ericholscher

  • Needs tests set

Need to provide tests.

comment:5 Changed 6 years ago by jacob

  • milestone changed from 1.1 to 1.2

comment:6 Changed 6 years ago by jcassee

  • Needs tests unset

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

Changed 6 years ago by jcassee

comment:7 Changed 6 years ago by SmileyChris

  • Patch needs improvement set

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

Changed 6 years ago by jcassee

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

comment:8 Changed 6 years ago by jcassee

  • Needs tests set
  • Patch needs improvement unset

Updated patch following SmileyChris' suggestions.

comment:9 Changed 6 years ago by jcassee

  • Needs tests unset
  • Owner changed from nobody to jcassee

comment:10 Changed 6 years ago by SmileyChris

  • Triage Stage changed from Accepted to Ready for checkin

comment:11 Changed 6 years ago by benspaulding

  • Cc benspaulding added

comment:12 Changed 6 years ago by jacob

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

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

comment:13 Changed 6 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 4 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

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