Skip to content

Commit 837f02c

Browse files
authored
Merge pull request jazzband#594 from malefice/master
Start Django 1.10 compatibility
2 parents b0f83b9 + baf1e6a commit 837f02c

File tree

6 files changed

+28
-4
lines changed

6 files changed

+28
-4
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ env:
1616
- TOXENV=pypy-django19
1717
- TOXENV=py34-django19
1818
- TOXENV=py35-django19
19+
- TOXENV=py27-django110
20+
- TOXENV=pypy-django110
21+
- TOXENV=py34-django110
22+
- TOXENV=py35-django110
1923
docsinstall: pip install -q tox
2024
before_install:
2125
- nvm install node

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ or just made Pipeline more awesome.
1818
* Andy Kish <[email protected]>
1919
* Ara Anjargolian <[email protected]>
2020
* Arnar Yngvason <[email protected]>
21+
* Austin Pua <[email protected]>
2122
* Axel Haustant <[email protected]>
2223
* Balazs Kossovics <[email protected]>
2324
* Ben Vinegar <[email protected]>

pipeline/collector.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from collections import OrderedDict
66

7+
import django
78
from django.contrib.staticfiles import finders
89
from django.contrib.staticfiles.storage import staticfiles_storage
910
from django.utils import six
@@ -19,6 +20,11 @@ def __init__(self, storage=None):
1920
storage = staticfiles_storage
2021
self.storage = storage
2122

23+
def _get_modified_time(self, storage, prefixed_path):
24+
if django.VERSION[:2] >= (1, 10):
25+
return storage.get_modified_time(prefixed_path)
26+
return storage.modified_time(prefixed_path)
27+
2228
def clear(self, path=""):
2329
dirs, files = self.storage.listdir(path)
2430
for f in files:
@@ -65,14 +71,14 @@ def delete_file(self, path, prefixed_path, source_storage):
6571
if self.storage.exists(prefixed_path):
6672
try:
6773
# When was the target file modified last time?
68-
target_last_modified = self.storage.modified_time(prefixed_path)
74+
target_last_modified = self._get_modified_time(self.storage, prefixed_path)
6975
except (OSError, NotImplementedError, AttributeError):
7076
# The storage doesn't support ``modified_time`` or failed
7177
pass
7278
else:
7379
try:
7480
# When was the source file modified last time?
75-
source_last_modified = source_storage.modified_time(path)
81+
source_last_modified = self._get_modified_time(source_storage, prefixed_path)
7682
except (OSError, NotImplementedError, AttributeError):
7783
pass
7884
else:

pipeline/middleware.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@
66

77
from pipeline.conf import settings
88

9+
try:
10+
# Support for Django 1.10 new MIDDLEWARE setting
11+
from django.utils.deprecation import MiddlewareMixin
12+
except ImportError: # Django < 1.10
13+
MiddlewareMixin = object
914

10-
class MinifyHTMLMiddleware(object):
15+
16+
class MinifyHTMLMiddleware(MiddlewareMixin):
1117
def __init__(self):
1218
if not settings.PIPELINE_ENABLED:
1319
raise MiddlewareNotUsed

tests/utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22

3+
import django
34
from django.conf import settings
45
from django.utils import six
56

@@ -17,6 +18,11 @@ def _(path):
1718

1819
class pipeline_settings(override_settings):
1920
def __init__(self, **kwargs):
21+
if django.VERSION[:2] >= (1, 10):
22+
# Django 1.10's override_settings inherits from TestContextDecorator
23+
# and its __init__ method calls its superclass' __init__ method too,
24+
# so we must do the same.
25+
super(pipeline_settings, self).__init__()
2026
self.options = {'PIPELINE': kwargs}
2127

2228

tox.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tox]
22
envlist =
3-
{py27,pypy,py34}-django{16,17,18,19},py35-django19,docs
3+
{py27,pypy,py34}-django{16,17,18,19,110},py35-django{19,110},docs
44

55
[testenv]
66
basepython =
@@ -15,6 +15,7 @@ deps =
1515
django17: Django>=1.7,<1.8
1616
django18: Django>=1.8,<1.9
1717
django19: Django>=1.9,<1.10
18+
django110: Django>=1.10,<1.11
1819
jinja2
1920
jsmin==2.2.0
2021
ply==3.4

0 commit comments

Comments
 (0)