Commit 837f02cd by Timothée Peignier Committed by GitHub

Merge pull request #594 from malefice/master

Start Django 1.10 compatibility
parents b0f83b9b baf1e6ab
......@@ -16,6 +16,10 @@ env:
- TOXENV=pypy-django19
- TOXENV=py34-django19
- TOXENV=py35-django19
- TOXENV=py27-django110
- TOXENV=pypy-django110
- TOXENV=py34-django110
- TOXENV=py35-django110
docsinstall: pip install -q tox
before_install:
- nvm install node
......
......@@ -18,6 +18,7 @@ or just made Pipeline more awesome.
* Andy Kish <agkish@gmail.com>
* Ara Anjargolian <ara818@gmail.com>
* Arnar Yngvason <arnar@hvitahusid.is>
* Austin Pua <pua.austin.anderson@gmail.com>
* Axel Haustant <noirbizarre@gmail.com>
* Balazs Kossovics <balazs.kossovics@e-loue.com>
* Ben Vinegar <ben@benv.ca>
......
......@@ -4,6 +4,7 @@ import os
from collections import OrderedDict
import django
from django.contrib.staticfiles import finders
from django.contrib.staticfiles.storage import staticfiles_storage
from django.utils import six
......@@ -19,6 +20,11 @@ class Collector(object):
storage = staticfiles_storage
self.storage = storage
def _get_modified_time(self, storage, prefixed_path):
if django.VERSION[:2] >= (1, 10):
return storage.get_modified_time(prefixed_path)
return storage.modified_time(prefixed_path)
def clear(self, path=""):
dirs, files = self.storage.listdir(path)
for f in files:
......@@ -65,14 +71,14 @@ class Collector(object):
if self.storage.exists(prefixed_path):
try:
# When was the target file modified last time?
target_last_modified = self.storage.modified_time(prefixed_path)
target_last_modified = self._get_modified_time(self.storage, prefixed_path)
except (OSError, NotImplementedError, AttributeError):
# The storage doesn't support ``modified_time`` or failed
pass
else:
try:
# When was the source file modified last time?
source_last_modified = source_storage.modified_time(path)
source_last_modified = self._get_modified_time(source_storage, prefixed_path)
except (OSError, NotImplementedError, AttributeError):
pass
else:
......
......@@ -6,8 +6,14 @@ from django.utils.html import strip_spaces_between_tags as minify_html
from pipeline.conf import settings
try:
# Support for Django 1.10 new MIDDLEWARE setting
from django.utils.deprecation import MiddlewareMixin
except ImportError: # Django < 1.10
MiddlewareMixin = object
class MinifyHTMLMiddleware(object):
class MinifyHTMLMiddleware(MiddlewareMixin):
def __init__(self):
if not settings.PIPELINE_ENABLED:
raise MiddlewareNotUsed
......
import os
import django
from django.conf import settings
from django.utils import six
......@@ -17,6 +18,11 @@ def _(path):
class pipeline_settings(override_settings):
def __init__(self, **kwargs):
if django.VERSION[:2] >= (1, 10):
# Django 1.10's override_settings inherits from TestContextDecorator
# and its __init__ method calls its superclass' __init__ method too,
# so we must do the same.
super(pipeline_settings, self).__init__()
self.options = {'PIPELINE': kwargs}
......
[tox]
envlist =
{py27,pypy,py34}-django{16,17,18,19},py35-django19,docs
{py27,pypy,py34}-django{16,17,18,19,110},py35-django{19,110},docs
[testenv]
basepython =
......@@ -15,6 +15,7 @@ deps =
django17: Django>=1.7,<1.8
django18: Django>=1.8,<1.9
django19: Django>=1.9,<1.10
django110: Django>=1.10,<1.11
jinja2
jsmin==2.2.0
ply==3.4
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment