def clear_image_cache(sender, instance, **kwargs): for field in instance._meta.fields: if isinstance(field, FileField): remove_cache(field.value_to_string(instance)) pre_save.connect(prepare_image_cache_cleanup) post_save.connect(clear_prepared_image_cache_cleanup) post_delete.connect(clear_image_cache) #reversion compatibility if 'reversion' in django_settings.INSTALLED_APPS: try: from reversion.models import pre_revision_commit, post_revision_commit pre_revision_commit.connect(prepare_image_cache_cleanup) post_revision_commit.connect(clear_prepared_image_cache_cleanup) except ImportError: pass # http://bakery-app01-static.s3.amazonaws.com/image/actuality/file0001116000079.jpg/image_token_73ff82d8ce1577a8a22f5a7d29a772a3ffc6e76c remove_directory('actuality/file0001116000079.jpg') ########NEW FILE######## __FILENAME__ = settings # coding=UTF-8 from django.conf import global_settings __author__ = 'franki' from django.conf import settings
if instance is None: return for field in instance._meta.fields: if isinstance(field, FileField): if instance.old_image_fields[field.attname] != field.value_to_string(instance): remove_cache(instance.old_image_fields[field.attname]) def clear_image_cache(sender, instance, **kwargs): for field in instance._meta.fields: if isinstance(field, FileField): remove_cache(field.value_to_string(instance)) pre_save.connect(prepare_image_cache_cleanup) post_save.connect(clear_prepared_image_cache_cleanup) post_delete.connect(clear_image_cache) #reversion compatibility if 'reversion' in django_settings.INSTALLED_APPS: try: from reversion.models import pre_revision_commit, post_revision_commit pre_revision_commit.connect(prepare_image_cache_cleanup) post_revision_commit.connect(clear_prepared_image_cache_cleanup) except ImportError: pass # http://bakery-app01-static.s3.amazonaws.com/image/actuality/file0001116000079.jpg/image_token_73ff82d8ce1577a8a22f5a7d29a772a3ffc6e76c remove_directory('actuality/file0001116000079.jpg')
def clearPreparedImageCacheCleanup(sender, instance=None, created=False, **kwargs): if created: return if instance is None: return for field in instance._meta.fields: if isinstance(field, FileField): if instance.old_image_fields[field.attname] != field.value_to_string(instance): removeCache(instance.old_image_fields[field.attname]) def clearImageCache(sender, instance, **kwargs): for field in instance._meta.fields: if isinstance(field, FileField): removeCache(field.value_to_string(instance)) pre_save.connect(prepareImageCacheCleanup) post_save.connect(clearPreparedImageCacheCleanup) post_delete.connect(clearImageCache) #reversion compatibility try: from reversion.models import pre_revision_commit, post_revision_commit pre_revision_commit.connect(prepareImageCacheCleanup) post_revision_commit.connect(clearPreparedImageCacheCleanup) except ImportError: pass