From 0a0708d2d6e34db6abbc5f204ab4c81d9be252a8 Mon Sep 17 00:00:00 2001 From: Pierre Dulac Date: Thu, 29 Oct 2015 23:03:48 +0100 Subject: [PATCH 01/16] Use a compat method to wrap the new way of retrieving the cache engine --- imagekit/cachefiles/backends.py | 3 +-- imagekit/utils.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/imagekit/cachefiles/backends.py b/imagekit/cachefiles/backends.py index 5e7025a..e615f2e 100644 --- a/imagekit/cachefiles/backends.py +++ b/imagekit/cachefiles/backends.py @@ -1,7 +1,6 @@ -from ..utils import get_singleton, sanitize_cache_key +from ..utils import get_singleton, get_cache, sanitize_cache_key import warnings from copy import copy -from django.core.cache import get_cache from django.core.exceptions import ImproperlyConfigured diff --git a/imagekit/utils.py b/imagekit/utils.py index 20ecda6..d768f57 100644 --- a/imagekit/utils.py +++ b/imagekit/utils.py @@ -151,6 +151,16 @@ def call_strategy_method(file, method_name): fn(file) +def get_cache(backend, **kwargs): + try: + from django.core.cache import caches + except ImportError: + from django.core.cache import get_cache + return get_cache(backend, **kwargs) + + return caches[backend] + + def sanitize_cache_key(key): if settings.IMAGEKIT_USE_MEMCACHED_SAFE_CACHE_KEY: # Memcached keys can't contain whitespace or control characters. From fbf15befb86da577c0bfa3c1794b01947f117208 Mon Sep 17 00:00:00 2001 From: Pierre Dulac Date: Thu, 29 Oct 2015 23:27:02 +0100 Subject: [PATCH 02/16] Do not take a decision on which cache to use in DEBUG mode maybe the developer wants to test his cache configuration locally, or maybe he has to test different types of caches, we just don't know --- imagekit/conf.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/imagekit/conf.py b/imagekit/conf.py index 2900da1..4485eb1 100644 --- a/imagekit/conf.py +++ b/imagekit/conf.py @@ -17,25 +17,16 @@ class ImageKitConf(AppConf): def configure_cache_backend(self, value): if value is None: - try: - from django.core.cache.backends.dummy import DummyCache - except ImportError: - dummy_cache = 'dummy://' - else: - dummy_cache = 'django.core.cache.backends.dummy.DummyCache' - # DEFAULT_CACHE_ALIAS doesn't exist in Django<=1.2 try: from django.core.cache import DEFAULT_CACHE_ALIAS as default_cache_alias except ImportError: default_cache_alias = 'default' - if settings.DEBUG: - value = dummy_cache - elif default_cache_alias in getattr(settings, 'CACHES', {}): + if default_cache_alias in getattr(settings, 'CACHES', {}): value = default_cache_alias else: - value = getattr(settings, 'CACHE_BACKEND', None) or dummy_cache + raise ValueError("The default cache alias '%s' is not available in CACHES" % value) return value From e155b632cdfc434e9b42f48ce4a15fe1f2623352 Mon Sep 17 00:00:00 2001 From: Pierre Dulac Date: Fri, 30 Oct 2015 00:24:50 +0100 Subject: [PATCH 03/16] Handle cases where DEFAULT_CACHE_ALIAS is None in old Django versions --- imagekit/conf.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/imagekit/conf.py b/imagekit/conf.py index 4485eb1..6bd39d1 100644 --- a/imagekit/conf.py +++ b/imagekit/conf.py @@ -19,7 +19,8 @@ class ImageKitConf(AppConf): if value is None: # DEFAULT_CACHE_ALIAS doesn't exist in Django<=1.2 try: - from django.core.cache import DEFAULT_CACHE_ALIAS as default_cache_alias + from django.core.cache import DEFAULT_CACHE_ALIAS + default_cache_alias = DEFAULT_CACHE_ALIAS or 'default' except ImportError: default_cache_alias = 'default' From 5855e97997c8c54913f15f1102cb298f084b5522 Mon Sep 17 00:00:00 2001 From: Pierre Dulac Date: Fri, 30 Oct 2015 16:23:28 +0100 Subject: [PATCH 04/16] Cleaner implementation thanks to @vstoykov explanation --- imagekit/conf.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/imagekit/conf.py b/imagekit/conf.py index 6bd39d1..4485eb1 100644 --- a/imagekit/conf.py +++ b/imagekit/conf.py @@ -19,8 +19,7 @@ class ImageKitConf(AppConf): if value is None: # DEFAULT_CACHE_ALIAS doesn't exist in Django<=1.2 try: - from django.core.cache import DEFAULT_CACHE_ALIAS - default_cache_alias = DEFAULT_CACHE_ALIAS or 'default' + from django.core.cache import DEFAULT_CACHE_ALIAS as default_cache_alias except ImportError: default_cache_alias = 'default' From 7f36f897f8a934900b505c454c887428a6b2feb8 Mon Sep 17 00:00:00 2001 From: Pierre Dulac Date: Sat, 31 Oct 2015 00:22:55 +0100 Subject: [PATCH 05/16] Update the doc to reflect the new `IMAGEKIT_CACHE_BACKEND` behavior --- docs/configuration.rst | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index 33b4f1f..f65ed52 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -44,11 +44,15 @@ Settings .. attribute:: IMAGEKIT_CACHE_BACKEND - :default: If ``DEBUG`` is ``True``, ``'django.core.cache.backends.dummy.DummyCache'``. - Otherwise, ``'default'``. + :default: ``'default'`` - The Django cache backend to be used to store information like the state of - cached images (i.e. validated or not). + The Django cache backend alias to retrieve the shared cache instance defined + in your settings, as described in the `Django cache section`_. + + The cache is then used to store information like the state of cached + images (i.e. validated or not). + +.. _`Django cache section`: https://docs.djangoproject.com/en/1.8/topics/cache/#accessing-the-cache .. attribute:: IMAGEKIT_CACHE_PREFIX From c858936e0c4f06dc5ce136b1bef9a192b3d12a16 Mon Sep 17 00:00:00 2001 From: Pierre Dulac Date: Sat, 31 Oct 2015 11:36:01 +0100 Subject: [PATCH 06/16] Add tox env for django 1.9 supported python versions can be found at https://docs.djangoproject.com/en/1.9/releases/1.9/ --- tox.ini | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 1c60ca2..7d0642d 100644 --- a/tox.ini +++ b/tox.ini @@ -1,14 +1,27 @@ [tox] envlist = - py34-django18, py34-django17, py34-django16, + py35-django19, + py34-django19, py34-django18, py34-django17, py34-django16, py33-django18, py33-django17, py33-django16, py33-django15, py32-django18, py32-django17, py32-django16, py32-django15, - py27-django18, py27-django17, py27-django16, py27-django15, py27-django14, py27-django13, py27-django12, + py27-django19, py27-django18, py27-django17, py27-django16, py27-django15, py27-django14, py27-django13, py27-django12, py26-django15, py26-django14, py26-django13, py26-django12 [testenv] commands = python setup.py test +[testenv:py35-django19] +basepython = python3.5 +deps = + git+https://github.com/django/django.git@stable/1.9.x#egg=Django + django-nose==1.4 + +[testenv:py34-django19] +basepython = python3.4 +deps = + git+https://github.com/django/django.git@stable/1.9.x#egg=Django + django-nose==1.4 + [testenv:py34-django18] basepython = python3.4 deps = @@ -70,6 +83,12 @@ basepython = python3.2 deps = Django>=1.5,<1.6 +[testenv:py27-django19] +basepython = python2.7 +deps = + git+https://github.com/django/django.git@stable/1.9.x#egg=Django + django-nose==1.4 + [testenv:py27-django18] basepython = python2.7 deps = From ecf5e892e24930d4b5c9c219800ccc462b519f12 Mon Sep 17 00:00:00 2001 From: Pierre Dulac Date: Sat, 31 Oct 2015 11:37:44 +0100 Subject: [PATCH 07/16] Use the env conf for travis to split the test builds --- .travis.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.travis.yml b/.travis.yml index 80c5fd1..2625e69 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,35 @@ language: python python: - 2.7 + +env: + - TOX_ENV=py26-django12 + - TOX_ENV=py26-django13 + - TOX_ENV=py26-django14 + - TOX_ENV=py26-django15 + - TOX_ENV=py26-django16 + - TOX_ENV=py27-django12 + - TOX_ENV=py27-django13 + - TOX_ENV=py27-django14 + - TOX_ENV=py27-django15 + - TOX_ENV=py27-django16 + - TOX_ENV=py27-django17 + - TOX_ENV=py27-django18 + - TOX_ENV=py27-django19 + - TOX_ENV=py32-django15 + - TOX_ENV=py32-django16 + - TOX_ENV=py32-django17 + - TOX_ENV=py32-django18 + - TOX_ENV=py33-django15 + - TOX_ENV=py33-django16 + - TOX_ENV=py33-django17 + - TOX_ENV=py33-django18 + - TOX_ENV=py34-django16 + - TOX_ENV=py34-django17 + - TOX_ENV=py34-django18 + - TOX_ENV=py34-django19 + - TOX_ENV=py35-django19 + install: pip install tox --use-mirrors script: tox notifications: From c89a63edbee94ec778039f205a9f69c9c57a3ffd Mon Sep 17 00:00:00 2001 From: Pierre Dulac Date: Sat, 31 Oct 2015 11:38:40 +0100 Subject: [PATCH 08/16] Allow travis to fail for the python3.5 interpreter not yet available --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index 2625e69..4e24a1d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,6 +30,11 @@ env: - TOX_ENV=py34-django19 - TOX_ENV=py35-django19 +matrix: + # Python 3.5 not yet available on travis, watch this to see when it is. + allow_failures: + - env: TOX_ENV=py35-django19 + install: pip install tox --use-mirrors script: tox notifications: From 820d2f00ebf2be52966baff9813f85ec2f231ad4 Mon Sep 17 00:00:00 2001 From: Pierre Dulac Date: Sat, 31 Oct 2015 11:39:06 +0100 Subject: [PATCH 09/16] Allow the test to fail fast --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 4e24a1d..2f1da0b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,7 @@ env: matrix: # Python 3.5 not yet available on travis, watch this to see when it is. + fast_finish: true allow_failures: - env: TOX_ENV=py35-django19 From b475de7b4815a0ea407c5d0e5621f711f0fd58c2 Mon Sep 17 00:00:00 2001 From: Pierre Dulac Date: Sat, 31 Oct 2015 11:39:46 +0100 Subject: [PATCH 10/16] Enable the new travis architecture for speed and reliability --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2f1da0b..c4f3902 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: python -python: - - 2.7 +python: "2.7" +sudo: false env: - TOX_ENV=py26-django12 From 6fabad9749e07175620901ccf129ea3d931e497f Mon Sep 17 00:00:00 2001 From: Pierre Dulac Date: Sat, 31 Oct 2015 11:43:17 +0100 Subject: [PATCH 11/16] Tells tox to only run the designated env --- .travis.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c4f3902..563884a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,7 +36,11 @@ matrix: allow_failures: - env: TOX_ENV=py35-django19 -install: pip install tox --use-mirrors -script: tox +install: + - pip install tox --use-mirrors + +script: + - tox -e $TOX_ENV + notifications: irc: "irc.freenode.org#imagekit" From 97dc4b6cb2e65f958a387f86e1a3c946f430c390 Mon Sep 17 00:00:00 2001 From: Pierre Dulac Date: Sat, 31 Oct 2015 18:51:07 +0100 Subject: [PATCH 12/16] Work a compatibility implementation for Django 1.2 --- imagekit/conf.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/imagekit/conf.py b/imagekit/conf.py index 4485eb1..84dffb6 100644 --- a/imagekit/conf.py +++ b/imagekit/conf.py @@ -23,10 +23,21 @@ class ImageKitConf(AppConf): except ImportError: default_cache_alias = 'default' - if default_cache_alias in getattr(settings, 'CACHES', {}): + caches = getattr(settings, 'CACHES', None) + if caches is None: + # Support Django<=1.2 there is no default `CACHES` setting + try: + from django.core.cache.backends.dummy import DummyCache + except ImportError: + dummy_cache = 'dummy://' + else: + dummy_cache = 'django.core.cache.backends.dummy.DummyCache' + return dummy_cache + + if default_cache_alias in caches: value = default_cache_alias else: - raise ValueError("The default cache alias '%s' is not available in CACHES" % value) + raise ValueError("The default cache alias '%s' is not available in CACHES" % default_cache_alias) return value From e79d2ba60ebe8c5ab711894ec519ca1f27af9944 Mon Sep 17 00:00:00 2001 From: Pierre Dulac Date: Sat, 31 Oct 2015 19:02:02 +0100 Subject: [PATCH 13/16] Add a missing env to the tox matrix --- tox.ini | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 7d0642d..744d234 100644 --- a/tox.ini +++ b/tox.ini @@ -5,7 +5,7 @@ envlist = py33-django18, py33-django17, py33-django16, py33-django15, py32-django18, py32-django17, py32-django16, py32-django15, py27-django19, py27-django18, py27-django17, py27-django16, py27-django15, py27-django14, py27-django13, py27-django12, - py26-django15, py26-django14, py26-django13, py26-django12 + py26-django16, py26-django15, py26-django14, py26-django13, py26-django12 [testenv] commands = python setup.py test @@ -128,6 +128,11 @@ deps = Django>=1.2,<1.3 django-nose==1.2 +[testenv:py26-django16] +basepython = python2.6 +deps = + Django>=1.6,<1.7 + [testenv:py26-django15] basepython = python2.6 deps = From cec8cd7780334167b80bdadc3984722c967740fc Mon Sep 17 00:00:00 2001 From: Pierre Dulac Date: Sat, 31 Oct 2015 19:12:35 +0100 Subject: [PATCH 14/16] Update django-nose version to work with Django 1.9 --- setup.py | 2 +- tox.ini | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 4406e49..f26c81a 100644 --- a/setup.py +++ b/setup.py @@ -46,7 +46,7 @@ setup( 'beautifulsoup4==4.1.3', 'nose>=1.3.6,<1.4', 'nose-progressive==1.5.1', - 'django-nose>=1.2,<=1.4', + 'django-nose>=1.2,<1.5', 'Pillow<3.0', 'mock==1.0.1', ], diff --git a/tox.ini b/tox.ini index 744d234..2bc14a5 100644 --- a/tox.ini +++ b/tox.ini @@ -14,13 +14,13 @@ commands = python setup.py test basepython = python3.5 deps = git+https://github.com/django/django.git@stable/1.9.x#egg=Django - django-nose==1.4 + django-nose==1.4.2 [testenv:py34-django19] basepython = python3.4 deps = git+https://github.com/django/django.git@stable/1.9.x#egg=Django - django-nose==1.4 + django-nose==1.4.2 [testenv:py34-django18] basepython = python3.4 @@ -87,7 +87,7 @@ deps = basepython = python2.7 deps = git+https://github.com/django/django.git@stable/1.9.x#egg=Django - django-nose==1.4 + git+https://github.com/django-nose/django-nose@master#egg=django-nose [testenv:py27-django18] basepython = python2.7 From 53fb3a872202ae3128fee16f9a1c585ca76736a2 Mon Sep 17 00:00:00 2001 From: Bryan Veloso Date: Tue, 8 Dec 2015 11:38:39 -0800 Subject: [PATCH 15/16] Bump version number. --- imagekit/pkgmeta.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imagekit/pkgmeta.py b/imagekit/pkgmeta.py index a7e84c8..e9fe7e0 100644 --- a/imagekit/pkgmeta.py +++ b/imagekit/pkgmeta.py @@ -1,5 +1,5 @@ __title__ = 'django-imagekit' __author__ = 'Matthew Tretter, Eric Eldredge, Bryan Veloso, Greg Newman, Chris Drackett, Justin Driscoll' -__version__ = '3.2.7' +__version__ = '3.3' __license__ = 'BSD' __all__ = ['__title__', '__author__', '__version__', '__license__'] From 7903efd9b7c2a484b3ee128b2f04ba3b33c02caf Mon Sep 17 00:00:00 2001 From: Bryan Veloso Date: Tue, 8 Dec 2015 11:39:03 -0800 Subject: [PATCH 16/16] Add @vstoykov to the author list. --- imagekit/pkgmeta.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imagekit/pkgmeta.py b/imagekit/pkgmeta.py index e9fe7e0..5872ac0 100644 --- a/imagekit/pkgmeta.py +++ b/imagekit/pkgmeta.py @@ -1,5 +1,5 @@ __title__ = 'django-imagekit' -__author__ = 'Matthew Tretter, Eric Eldredge, Bryan Veloso, Greg Newman, Chris Drackett, Justin Driscoll' +__author__ = 'Matthew Tretter, Venelin Stoykov, Eric Eldredge, Bryan Veloso, Greg Newman, Chris Drackett, Justin Driscoll' __version__ = '3.3' __license__ = 'BSD' __all__ = ['__title__', '__author__', '__version__', '__license__']