Browse Source

Fixed #20349 -- Moved setting_changed signal to django.core.signals.

This removes the need to load django.test when not testing.
Collin Anderson 10 years ago
parent
commit
5dddd79433

+ 1 - 1
django/contrib/auth/hashers.py

@@ -8,7 +8,7 @@ import importlib
 
 from django.dispatch import receiver
 from django.conf import settings
-from django.test.signals import setting_changed
+from django.core.signals import setting_changed
 from django.utils.encoding import force_bytes, force_str, force_text
 from django.core.exceptions import ImproperlyConfigured
 from django.utils.crypto import (

+ 1 - 0
django/core/signals.py

@@ -3,3 +3,4 @@ from django.dispatch import Signal
 request_started = Signal(providing_args=["environ"])
 request_finished = Signal()
 got_request_exception = Signal(providing_args=["request"])
+setting_changed = Signal(providing_args=["setting", "value", "enter"])

+ 1 - 2
django/test/signals.py

@@ -4,6 +4,7 @@ import threading
 import warnings
 
 from django.conf import settings
+from django.core.signals import setting_changed
 from django.db import connections, router
 from django.db.utils import ConnectionRouter
 from django.dispatch import receiver, Signal
@@ -12,8 +13,6 @@ from django.utils.functional import empty
 
 template_rendered = Signal(providing_args=["template", "context"])
 
-setting_changed = Signal(providing_args=["setting", "value", "enter"])
-
 # Most setting_changed receivers are supposed to be added below,
 # except for cases where the receiver is related to a contrib app.
 

+ 1 - 1
django/utils/translation/trans_real.py

@@ -13,8 +13,8 @@ from django.apps import apps
 from django.conf import settings
 from django.conf.locale import LANG_INFO
 from django.core.exceptions import AppRegistryNotReady
+from django.core.signals import setting_changed
 from django.dispatch import receiver
-from django.test.signals import setting_changed
 from django.utils.deprecation import RemovedInDjango19Warning
 from django.utils.encoding import force_text
 from django.utils._os import upath

+ 7 - 0
docs/ref/signals.txt

@@ -666,6 +666,13 @@ It's actually sent twice: when the new value is applied ("setup") and when the
 original value is restored ("teardown"). Use the ``enter`` argument to
 distinguish between the two.
 
+You can also import this signal from ``django.core.signals`` to avoid importing
+from ``django.test`` in non-test situations.
+
+.. versionchanged:: 1.8
+
+    The signal was moved to ``django.core.signals`` as described above.
+
 Arguments sent with this signal:
 
 ``sender``

+ 4 - 0
docs/releases/1.8.txt

@@ -460,6 +460,10 @@ Signals
   the request, was added to the :data:`~django.core.signals.request_started`
   signal.
 
+* You can now import the :func:`~django.test.signals.setting_changed` signal
+  from ``django.core.signals`` to avoid loading ``django.test`` in non-test
+  situations. Django no longer does so itself.
+
 System Check Framework
 ^^^^^^^^^^^^^^^^^^^^^^