☀️ Moved the signal to its own file to avoid import errors

This commit is contained in:
Camilo Nova 2016-09-14 14:50:39 -05:00
parent 9d4d0ab334
commit 395efc992f
5 changed files with 8 additions and 10 deletions

View file

@ -1,4 +1,3 @@
import django.dispatch
from django.utils.functional import LazyObject
__version__ = '1.3'
@ -13,5 +12,3 @@ class LazyConfig(LazyObject):
config = LazyConfig()
updated_signal = django.dispatch.Signal(providing_args=['key', 'value'])

View file

@ -4,8 +4,7 @@ from django.core.exceptions import ImproperlyConfigured
from django.db.models.signals import post_save
from .. import Backend
from ... import settings
from ... import updated_signal
from ... import settings, signals
class DatabaseBackend(Backend):
@ -87,7 +86,7 @@ class DatabaseBackend(Backend):
if self._cache:
self._cache.set(key, value)
updated_signal.send(sender='constance', key=key, value=value)
signals.updated_signal.send(sender='constance', key=key, value=value)
def clear(self, sender, instance, created, **kwargs):
if self._cache and not created:

View file

@ -3,8 +3,7 @@ from django.utils import six
from django.utils.six.moves import zip
from . import Backend
from .. import settings, utils
from .. import updated_signal
from .. import settings, utils, signals
try:
from cPickle import loads, dumps
@ -50,4 +49,4 @@ class RedisBackend(Backend):
def set(self, key, value):
self._rd.set(self.add_prefix(key), dumps(value))
updated_signal.send(sender='constance', key=key, value=value)
signals.updated_signal.send(sender='constance', key=key, value=value)

3
constance/signals.py Normal file
View file

@ -0,0 +1,3 @@
import django.dispatch
updated_signal = django.dispatch.Signal(providing_args=['key', 'value'])

View file

@ -78,7 +78,7 @@ You can use it as:
.. code-block:: python
from constance import updated_signal
from constance.signals import updated_signal
@receiver(updated_signal)
def constance_updated(sender, key, value, **kwargs):