Skip to content

Commit

Permalink
Merge branch 'release/3.3'
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
bryanveloso committed Dec 8, 2015
2 parents 96f0b5d + 7903efd commit bc93ec2
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 27 deletions.
47 changes: 43 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,46 @@
language: python
python:
- 2.7
install: pip install tox --use-mirrors
script: tox
python: "2.7"
sudo: false

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

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

install:
- pip install tox --use-mirrors

script:
- tox -e $TOX_ENV

notifications:
irc: "irc.freenode.org#imagekit"
12 changes: 8 additions & 4 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions imagekit/cachefiles/backends.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
24 changes: 13 additions & 11 deletions imagekit/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,27 @@ 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', {}):
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:
value = getattr(settings, 'CACHE_BACKEND', None) or dummy_cache
raise ValueError("The default cache alias '%s' is not available in CACHES" % default_cache_alias)

return value

Expand Down
4 changes: 2 additions & 2 deletions imagekit/pkgmeta.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__title__ = 'django-imagekit'
__author__ = 'Matthew Tretter, Eric Eldredge, Bryan Veloso, Greg Newman, Chris Drackett, Justin Driscoll'
__version__ = '3.2.7'
__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__']
10 changes: 10 additions & 0 deletions imagekit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def exec_file(filepath, globalz=None, localz=None):
'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',
],
Expand Down
30 changes: 27 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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,
py26-django15, py26-django14, py26-django13, py26-django12
py27-django19, py27-django18, py27-django17, py27-django16, py27-django15, py27-django14, py27-django13, py27-django12,
py26-django16, 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.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.2

[testenv:py34-django18]
basepython = python3.4
deps =
Expand Down Expand Up @@ -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
git+https://github.com/django-nose/django-nose@master#egg=django-nose

[testenv:py27-django18]
basepython = python2.7
deps =
Expand Down Expand Up @@ -109,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 =
Expand Down

0 comments on commit bc93ec2

Please sign in to comment.