Skip to content

Commit bc93ec2

Browse files
committed
Merge branch 'release/3.3'
* release/3.3: Add @vstoykov to the author list. Bump version number. Update django-nose version to work with Django 1.9 Add a missing env to the tox matrix Work a compatibility implementation for Django 1.2 Tells tox to only run the designated env Enable the new travis architecture for speed and reliability Allow the test to fail fast Allow travis to fail for the python3.5 interpreter not yet available Use the env conf for travis to split the test builds Add tox env for django 1.9 Update the doc to reflect the new `IMAGEKIT_CACHE_BACKEND` behavior Cleaner implementation thanks to @vstoykov explanation Handle cases where DEFAULT_CACHE_ALIAS is None in old Django versions Do not take a decision on which cache to use in DEBUG mode Use a compat method to wrap the new way of retrieving the cache engine
2 parents 96f0b5d + 7903efd commit bc93ec2

File tree

8 files changed

+105
-27
lines changed

8 files changed

+105
-27
lines changed

.travis.yml

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,46 @@
11
language: python
2-
python:
3-
- 2.7
4-
install: pip install tox --use-mirrors
5-
script: tox
2+
python: "2.7"
3+
sudo: false
4+
5+
env:
6+
- TOX_ENV=py26-django12
7+
- TOX_ENV=py26-django13
8+
- TOX_ENV=py26-django14
9+
- TOX_ENV=py26-django15
10+
- TOX_ENV=py26-django16
11+
- TOX_ENV=py27-django12
12+
- TOX_ENV=py27-django13
13+
- TOX_ENV=py27-django14
14+
- TOX_ENV=py27-django15
15+
- TOX_ENV=py27-django16
16+
- TOX_ENV=py27-django17
17+
- TOX_ENV=py27-django18
18+
- TOX_ENV=py27-django19
19+
- TOX_ENV=py32-django15
20+
- TOX_ENV=py32-django16
21+
- TOX_ENV=py32-django17
22+
- TOX_ENV=py32-django18
23+
- TOX_ENV=py33-django15
24+
- TOX_ENV=py33-django16
25+
- TOX_ENV=py33-django17
26+
- TOX_ENV=py33-django18
27+
- TOX_ENV=py34-django16
28+
- TOX_ENV=py34-django17
29+
- TOX_ENV=py34-django18
30+
- TOX_ENV=py34-django19
31+
- TOX_ENV=py35-django19
32+
33+
matrix:
34+
# Python 3.5 not yet available on travis, watch this to see when it is.
35+
fast_finish: true
36+
allow_failures:
37+
- env: TOX_ENV=py35-django19
38+
39+
install:
40+
- pip install tox --use-mirrors
41+
42+
script:
43+
- tox -e $TOX_ENV
44+
645
notifications:
746
irc: "irc.freenode.org#imagekit"

docs/configuration.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,15 @@ Settings
4444

4545
.. attribute:: IMAGEKIT_CACHE_BACKEND
4646

47-
:default: If ``DEBUG`` is ``True``, ``'django.core.cache.backends.dummy.DummyCache'``.
48-
Otherwise, ``'default'``.
47+
:default: ``'default'``
4948

50-
The Django cache backend to be used to store information like the state of
51-
cached images (i.e. validated or not).
49+
The Django cache backend alias to retrieve the shared cache instance defined
50+
in your settings, as described in the `Django cache section`_.
51+
52+
The cache is then used to store information like the state of cached
53+
images (i.e. validated or not).
54+
55+
.. _`Django cache section`: https://docs.djangoproject.com/en/1.8/topics/cache/#accessing-the-cache
5256

5357

5458
.. attribute:: IMAGEKIT_CACHE_PREFIX

imagekit/cachefiles/backends.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
from ..utils import get_singleton, sanitize_cache_key
1+
from ..utils import get_singleton, get_cache, sanitize_cache_key
22
import warnings
33
from copy import copy
4-
from django.core.cache import get_cache
54
from django.core.exceptions import ImproperlyConfigured
65

76

imagekit/conf.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,27 @@ class ImageKitConf(AppConf):
1717

1818
def configure_cache_backend(self, value):
1919
if value is None:
20-
try:
21-
from django.core.cache.backends.dummy import DummyCache
22-
except ImportError:
23-
dummy_cache = 'dummy://'
24-
else:
25-
dummy_cache = 'django.core.cache.backends.dummy.DummyCache'
26-
2720
# DEFAULT_CACHE_ALIAS doesn't exist in Django<=1.2
2821
try:
2922
from django.core.cache import DEFAULT_CACHE_ALIAS as default_cache_alias
3023
except ImportError:
3124
default_cache_alias = 'default'
3225

33-
if settings.DEBUG:
34-
value = dummy_cache
35-
elif default_cache_alias in getattr(settings, 'CACHES', {}):
26+
caches = getattr(settings, 'CACHES', None)
27+
if caches is None:
28+
# Support Django<=1.2 there is no default `CACHES` setting
29+
try:
30+
from django.core.cache.backends.dummy import DummyCache
31+
except ImportError:
32+
dummy_cache = 'dummy://'
33+
else:
34+
dummy_cache = 'django.core.cache.backends.dummy.DummyCache'
35+
return dummy_cache
36+
37+
if default_cache_alias in caches:
3638
value = default_cache_alias
3739
else:
38-
value = getattr(settings, 'CACHE_BACKEND', None) or dummy_cache
40+
raise ValueError("The default cache alias '%s' is not available in CACHES" % default_cache_alias)
3941

4042
return value
4143

imagekit/pkgmeta.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__title__ = 'django-imagekit'
2-
__author__ = 'Matthew Tretter, Eric Eldredge, Bryan Veloso, Greg Newman, Chris Drackett, Justin Driscoll'
3-
__version__ = '3.2.7'
2+
__author__ = 'Matthew Tretter, Venelin Stoykov, Eric Eldredge, Bryan Veloso, Greg Newman, Chris Drackett, Justin Driscoll'
3+
__version__ = '3.3'
44
__license__ = 'BSD'
55
__all__ = ['__title__', '__author__', '__version__', '__license__']

imagekit/utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,16 @@ def call_strategy_method(file, method_name):
151151
fn(file)
152152

153153

154+
def get_cache(backend, **kwargs):
155+
try:
156+
from django.core.cache import caches
157+
except ImportError:
158+
from django.core.cache import get_cache
159+
return get_cache(backend, **kwargs)
160+
161+
return caches[backend]
162+
163+
154164
def sanitize_cache_key(key):
155165
if settings.IMAGEKIT_USE_MEMCACHED_SAFE_CACHE_KEY:
156166
# Memcached keys can't contain whitespace or control characters.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def exec_file(filepath, globalz=None, localz=None):
4646
'beautifulsoup4==4.1.3',
4747
'nose>=1.3.6,<1.4',
4848
'nose-progressive==1.5.1',
49-
'django-nose>=1.2,<=1.4',
49+
'django-nose>=1.2,<1.5',
5050
'Pillow<3.0',
5151
'mock==1.0.1',
5252
],

tox.ini

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
11
[tox]
22
envlist =
3-
py34-django18, py34-django17, py34-django16,
3+
py35-django19,
4+
py34-django19, py34-django18, py34-django17, py34-django16,
45
py33-django18, py33-django17, py33-django16, py33-django15,
56
py32-django18, py32-django17, py32-django16, py32-django15,
6-
py27-django18, py27-django17, py27-django16, py27-django15, py27-django14, py27-django13, py27-django12,
7-
py26-django15, py26-django14, py26-django13, py26-django12
7+
py27-django19, py27-django18, py27-django17, py27-django16, py27-django15, py27-django14, py27-django13, py27-django12,
8+
py26-django16, py26-django15, py26-django14, py26-django13, py26-django12
89

910
[testenv]
1011
commands = python setup.py test
1112

13+
[testenv:py35-django19]
14+
basepython = python3.5
15+
deps =
16+
git+https://github.com/django/django.git@stable/1.9.x#egg=Django
17+
django-nose==1.4.2
18+
19+
[testenv:py34-django19]
20+
basepython = python3.4
21+
deps =
22+
git+https://github.com/django/django.git@stable/1.9.x#egg=Django
23+
django-nose==1.4.2
24+
1225
[testenv:py34-django18]
1326
basepython = python3.4
1427
deps =
@@ -70,6 +83,12 @@ basepython = python3.2
7083
deps =
7184
Django>=1.5,<1.6
7285

86+
[testenv:py27-django19]
87+
basepython = python2.7
88+
deps =
89+
git+https://github.com/django/django.git@stable/1.9.x#egg=Django
90+
git+https://github.com/django-nose/django-nose@master#egg=django-nose
91+
7392
[testenv:py27-django18]
7493
basepython = python2.7
7594
deps =
@@ -109,6 +128,11 @@ deps =
109128
Django>=1.2,<1.3
110129
django-nose==1.2
111130

131+
[testenv:py26-django16]
132+
basepython = python2.6
133+
deps =
134+
Django>=1.6,<1.7
135+
112136
[testenv:py26-django15]
113137
basepython = python2.6
114138
deps =

0 commit comments

Comments
 (0)