mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-03-16 21:30:23 +00:00
Remove source_deleted signal
...for now. Eventually, we will want a signal that tells us when sources are no longer used, however that isn't just limited to when they're deleted! This new signal should also be dispatched, for example, when a source image field is set to `None`. Since none of the built-in strategies are currently using the source_deleted signal, I've decided to remove it until we have a more complete solution.
This commit is contained in:
parent
535e68aea6
commit
f9d91c7c4d
5 changed files with 7 additions and 17 deletions
|
|
@ -122,7 +122,7 @@ The answer is that, when you define an ImageSpecField, ImageKit automatically
|
|||
creates and registers an object called a *source group*. Source groups are
|
||||
responsible for two things:
|
||||
|
||||
1. They dispatch signals when a source is created, changed, or deleted, and
|
||||
1. They dispatch signals when a source is saved, and
|
||||
2. They expose a generator method that enumerates source files.
|
||||
|
||||
When these objects are registered (using ``imagekit.register.source_group()``),
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ Cache File Strategy
|
|||
-------------------
|
||||
|
||||
Each ``ImageCacheFile`` has a cache file strategy, which abstracts away when
|
||||
image is actually generated. It can implement the following four methods:
|
||||
image is actually generated. It can implement the following three methods:
|
||||
|
||||
* ``on_content_required`` - called by ``ImageCacheFile`` when it requires the
|
||||
contents of the generated image. For example, when you call ``read()`` or
|
||||
|
|
@ -42,7 +42,6 @@ image is actually generated. It can implement the following four methods:
|
|||
generated image to exist but may not be concerned with its contents. For
|
||||
example, when you access its ``url`` or ``path`` attribute.
|
||||
* ``on_source_saved`` - called when the source of a spec is saved
|
||||
* ``on_source_deleted`` - called when the source of a spec is deleted
|
||||
|
||||
The default strategy only defines the first two of these, as follows:
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
from .exceptions import AlreadyRegistered, NotRegistered
|
||||
from .signals import (content_required, existence_required, source_saved,
|
||||
source_deleted)
|
||||
from .signals import content_required, existence_required, source_saved
|
||||
from .utils import call_strategy_method
|
||||
|
||||
|
||||
|
|
@ -71,7 +70,6 @@ class SourceGroupRegistry(object):
|
|||
"""
|
||||
_signals = {
|
||||
source_saved: 'on_source_saved',
|
||||
source_deleted: 'on_source_deleted',
|
||||
}
|
||||
|
||||
def __init__(self):
|
||||
|
|
|
|||
|
|
@ -7,4 +7,3 @@ existence_required = Signal()
|
|||
|
||||
# Source group signals
|
||||
source_saved = Signal()
|
||||
source_deleted = Signal()
|
||||
|
|
|
|||
|
|
@ -2,19 +2,19 @@
|
|||
Source groups are the means by which image spec sources are identified. They
|
||||
have two responsibilities:
|
||||
|
||||
1. To dispatch ``source_saved``, and ``source_deleted`` signals. (These will be
|
||||
relayed to the corresponding specs' cache file strategies.)
|
||||
1. To dispatch ``source_saved`` signals. (These will be relayed to the
|
||||
corresponding specs' cache file strategies.)
|
||||
2. To provide the source files that they represent, via a generator method named
|
||||
``files()``. (This is used by the generateimages management command for
|
||||
"pre-caching" image files.)
|
||||
|
||||
"""
|
||||
|
||||
from django.db.models.signals import post_init, post_save, post_delete
|
||||
from django.db.models.signals import post_init, post_save
|
||||
from django.utils.functional import wraps
|
||||
import inspect
|
||||
from ..cachefiles import LazyImageCacheFile
|
||||
from ..signals import source_saved, source_deleted
|
||||
from ..signals import source_saved
|
||||
from ..utils import get_nonabstract_descendants
|
||||
|
||||
|
||||
|
|
@ -57,7 +57,6 @@ class ModelSignalRouter(object):
|
|||
uid = 'ik_spec_field_receivers'
|
||||
post_init.connect(self.post_init_receiver, dispatch_uid=uid)
|
||||
post_save.connect(self.post_save_receiver, dispatch_uid=uid)
|
||||
post_delete.connect(self.post_delete_receiver, dispatch_uid=uid)
|
||||
|
||||
def add(self, source_group):
|
||||
self._source_groups.append(source_group)
|
||||
|
|
@ -97,11 +96,6 @@ class ModelSignalRouter(object):
|
|||
self.dispatch_signal(source_saved, file, sender, instance,
|
||||
attname)
|
||||
|
||||
@ik_model_receiver
|
||||
def post_delete_receiver(self, sender, instance=None, **kwargs):
|
||||
for attname, file in self.get_field_dict(instance).items():
|
||||
self.dispatch_signal(source_deleted, file, sender, instance, attname)
|
||||
|
||||
@ik_model_receiver
|
||||
def post_init_receiver(self, sender, instance=None, **kwargs):
|
||||
self.update_source_hashes(instance)
|
||||
|
|
|
|||
Loading…
Reference in a new issue