Skip to content

Commit

Permalink
Merge pull request #43 from michaelkuty/master
Browse files Browse the repository at this point in the history
django 1.8 +, update setup.py, tests, fixed #41 and merged #42, #38
  • Loading branch information
codeinthehole committed Dec 6, 2015
2 parents 532ec63 + 8dfa766 commit 05ba864
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ dist/*
.coverage
TODO
.tox
__pycache__
29 changes: 22 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
language: python
python: 2.7
sudo: false

python:
- 2.7
- 3.3
- 3.4
- "pypy"
env:
- TOX_ENV=py27-django15
- TOX_ENV=py27-django16
- TOX_ENV=py27-django17
- TOX_ENV=py27-django18
- TOX_ENV=py33-django15
- TOX_ENV=py33-django16
- TOX_ENV=py33-django17
- TOX_ENV=py33-django18
- TOX_ENV=py34-django15
- TOX_ENV=py34-django16
- TOX_ENV=py34-django17
- TOX_ENV=py34-django18
- TOX_ENV=pypy-django15
- TOX_ENV=pypy-django16
- TOX_ENV=pypy-django17
- TOX_ENV=pypy-django18
- TOX_ENV=py27-django14

install:
- make test
- pip install tox

script:
- ./runtests.py
- tox -e $TOX_ENV
2 changes: 2 additions & 0 deletions cacheback/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
__version__ = '1.0-dev'

default_app_config = 'cacheback.conf.CachebackConfig'
3 changes: 2 additions & 1 deletion cacheback/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import hashlib
import collections

from django.core.cache import get_cache, DEFAULT_CACHE_ALIAS
from django.core.cache import DEFAULT_CACHE_ALIAS
from django.conf import settings
import six

from cacheback import tasks
from cacheback.utils import get_cache

logger = logging.getLogger('cacheback')

Expand Down
7 changes: 7 additions & 0 deletions cacheback/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _


class CachebackConfig(AppConfig):
name = 'cacheback'
verbose_name = _('Cacheback')
5 changes: 4 additions & 1 deletion cacheback/function.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from django.utils import importlib
try:
import importlib
except ImportError:
import django.utils.importlib as importlib

from cacheback.base import Job

Expand Down
6 changes: 4 additions & 2 deletions cacheback/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

from celery.task import task
from celery.utils.log import get_task_logger
from django.utils import importlib

try:
import importlib
except ImportError:
import django.utils.importlib as importlib

logger = get_task_logger(__name__)

Expand Down
22 changes: 22 additions & 0 deletions cacheback/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from django.core import signals


def get_cache(backend, **kwargs):
"""
Compatibilty wrapper for getting Django's cache backend instance
original source: https://github.com/vstoykov/django-imagekit/commit/c26f8a0538778969a64ee471ce99b25a04865a8e
"""
try:
from django.core.cache import _create_cache
except ImportError:
# Django < 1.7
from django.core.cache import get_cache as _get_cache
return _get_cache(backend, **kwargs)

cache = _create_cache(backend, **kwargs)
# Some caches -- python-memcached in particular -- need to do a cleanup at the
# end of a request cycle. If not implemented in a particular backend
# cache.close is a no-op
signals.request_finished.connect(cache.close)
return cache
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
packages=find_packages(exclude=["sandbox*", "tests*"]),
include_package_data=True,
install_requires=[
'django>=1.3,<1.7',
'django>=1.3,<1.9',
'django-celery>=3.0',
'celery<3.2',
'six',
Expand Down
2 changes: 1 addition & 1 deletion test_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
django-nose==1.3
django-nose==1.4.1
nose==1.3.4
pinocchio==0.4.2
mock==1.0.1
Expand Down
19 changes: 8 additions & 11 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
[tox]
envlist=py27,py34,pypy
envlist=py{27,33,34,py}-django{15,16,17,18},py27-django14

[testenv]
deps = -r{toxinidir}/test_requirements.txt
deps =
-r{toxinidir}/test_requirements.txt
django14: Django>=1.4,<1.5
django15: Django>=1.5,<1.6
django16: Django>=1.6,<1.7
django17: Django>=1.7,<1.8
django18: Django==1.8.3
commands = python runtests.py []

[testenv:py27]
basepython = python2.7

[testenv:py34]
basepython = python3.4

[testenv:pypy]
basepython = pypy

0 comments on commit 05ba864

Please sign in to comment.