Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[1.1.X] Fixed #10130: you may now delete attributes on `settings`. Th…

…anks, jcassee.

Backport of r11824.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@11825 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit c1a8bd6779c2ff907d2d80b98d79c8ab10d642ae 1 parent 5e6c3d2
@jacobian jacobian authored
View
7 django/utils/functional.py
@@ -280,6 +280,13 @@ def __setattr__(self, name, value):
self._setup()
setattr(self._wrapped, name, value)
+ def __delattr__(self, name):
+ if name == "_wrapped":
+ raise TypeError("can't delete _wrapped.")
+ if self._wrapped is None:
+ self._setup()
+ delattr(self._wrapped, name)
+
def _setup(self):
"""
Must be implemented by subclasses to initialise the wrapped object.
View
0  tests/regressiontests/settings/__init__.py
No changes.
View
0  tests/regressiontests/settings/models.py
No changes.
View
17 tests/regressiontests/settings/tests.py
@@ -0,0 +1,17 @@
+import unittest
+from django.conf import settings
+
+class SettingsTests(unittest.TestCase):
+
+ #
+ # Regression tests for #10130: deleting settings.
+ #
+
+ def test_settings_delete(self):
+ settings.TEST = 'test'
+ self.assertEqual('test', settings.TEST)
+ del settings.TEST
+ self.assertRaises(AttributeError, getattr, settings, 'TEST')
+
+ def test_settings_delete_wrapped(self):
+ self.assertRaises(TypeError, delattr, settings, '_wrapped')
Please sign in to comment.
Something went wrong with that request. Please try again.