Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'release/0.6.2'

  • Loading branch information...
commit d4ce5824aa1d7e116ef7c344feb558718941d77d 2 parents 5b0fd7e + 98ccd0d
@jezdez jezdez authored
View
2  .gitignore
@@ -1,7 +1,7 @@
build
compressor/tests/media/CACHE
compressor/tests/media/custom
-compressor/tests/media/js/dc78a3f5af20.js
+compressor/tests/media/js/3f33b9146e12.js
dist
MANIFEST
*.pyc
View
2  compressor/__init__.py
@@ -1,4 +1,4 @@
-VERSION = (0, 6, 1, "f", 0) # following PEP 386
+VERSION = (0, 6, 2, "f", 0) # following PEP 386
DEV_N = None
View
32 compressor/base.py
@@ -51,20 +51,22 @@ def get_filename(self, url):
basename = url.replace(base_url, "", 1)
# drop the querystring, which is used for non-compressed cache-busting.
basename = basename.split("?", 1)[0]
- # first try finding the file in the root
- filename = os.path.join(settings.COMPRESS_ROOT, basename)
- if not os.path.exists(filename):
- # if not found and staticfiles is installed, use it
- if self.finders:
- filename = self.finders.find(basename)
- if filename:
- return filename
- # or just raise an exception as the last resort
- raise UncompressableFileError(
- "'%s' could not be found in the COMPRESS_ROOT '%s'%s" % (
- basename, settings.COMPRESS_ROOT,
- self.finders and " or with staticfiles." or "."))
- return filename
+ # first try to find it with staticfiles (in debug mode)
+ filename = None
+ if settings.DEBUG and self.finders:
+ filename = self.finders.find(basename)
+ # secondly try finding the file in the root
+ else:
+ root_filename = os.path.join(settings.COMPRESS_ROOT, basename)
+ if os.path.exists(root_filename):
+ filename = root_filename
+ if filename:
+ return filename
+ # or just raise an exception as the last resort
+ raise UncompressableFileError(
+ "'%s' could not be found in the COMPRESS_ROOT '%s'%s" % (
+ basename, settings.COMPRESS_ROOT,
+ self.finders and " or with staticfiles." or "."))
@cached_property
def parser(self):
@@ -190,7 +192,7 @@ def output_file(self, mode, content, forced=False):
The output method that saves the content to a file and renders
the appropriate template with the file's URL.
"""
- new_filepath = self.filepath(self.content)
+ new_filepath = self.filepath(content)
if not self.storage.exists(new_filepath) or forced:
self.storage.save(new_filepath, ContentFile(content))
url = self.storage.url(new_filepath)
View
6 compressor/templatetags/compress.py
@@ -98,11 +98,9 @@ def render(self, context, forced=False):
if cache_key:
self.cache_set(cache_key, rendered_output)
return rendered_output
- except:
+ except Exception, e:
if settings.DEBUG or forced:
- # Be very loud about the exception we just encountered
- from traceback import format_exc
- raise Exception(format_exc())
+ raise e
# 5. Or don't do anything in production
return self.nodelist.render(context)
View
30 compressor/tests/tests.py
@@ -76,7 +76,7 @@ def test_css_hash(self):
self.assertEqual('666f3aa8eacd', self.css_node.hash(self.css))
def test_css_return_if_on(self):
- output = u'<link rel="stylesheet" href="/media/CACHE/css/277b26db9a98.css" type="text/css">'
+ output = u'<link rel="stylesheet" href="/media/CACHE/css/f7c661b7a124.css" type="text/css">'
self.assertEqual(output, self.css_node.output().strip())
def test_js_split(self):
@@ -111,20 +111,20 @@ def test_js_return_if_off(self):
settings.COMPRESS_PRECOMPILERS = precompilers
def test_js_return_if_on(self):
- output = u'<script type="text/javascript" src="/media/CACHE/js/dc78a3f5af20.js" charset="utf-8"></script>'
+ output = u'<script type="text/javascript" src="/media/CACHE/js/3f33b9146e12.js" charset="utf-8"></script>'
self.assertEqual(output, self.js_node.output())
def test_custom_output_dir(self):
try:
old_output_dir = settings.COMPRESS_OUTPUT_DIR
settings.COMPRESS_OUTPUT_DIR = 'custom'
- output = u'<script type="text/javascript" src="/media/custom/js/dc78a3f5af20.js" charset="utf-8"></script>'
+ output = u'<script type="text/javascript" src="/media/custom/js/3f33b9146e12.js" charset="utf-8"></script>'
self.assertEqual(output, JsCompressor(self.js).output())
settings.COMPRESS_OUTPUT_DIR = ''
- output = u'<script type="text/javascript" src="/media/js/dc78a3f5af20.js" charset="utf-8"></script>'
+ output = u'<script type="text/javascript" src="/media/js/3f33b9146e12.js" charset="utf-8"></script>'
self.assertEqual(output, JsCompressor(self.js).output())
settings.COMPRESS_OUTPUT_DIR = '/custom/nested/'
- output = u'<script type="text/javascript" src="/media/custom/nested/js/dc78a3f5af20.js" charset="utf-8"></script>'
+ output = u'<script type="text/javascript" src="/media/custom/nested/js/3f33b9146e12.js" charset="utf-8"></script>'
self.assertEqual(output, JsCompressor(self.js).output())
finally:
settings.COMPRESS_OUTPUT_DIR = old_output_dir
@@ -291,7 +291,7 @@ def test_css_tag(self):
{% endcompress %}
"""
context = { 'MEDIA_URL': settings.COMPRESS_URL }
- out = u'<link rel="stylesheet" href="/media/CACHE/css/277b26db9a98.css" type="text/css">'
+ out = u'<link rel="stylesheet" href="/media/CACHE/css/f7c661b7a124.css" type="text/css">'
self.assertEqual(out, render(template, context))
def test_nonascii_css_tag(self):
@@ -301,7 +301,7 @@ def test_nonascii_css_tag(self):
{% endcompress %}
"""
context = { 'MEDIA_URL': settings.COMPRESS_URL }
- out = '<link rel="stylesheet" href="/media/CACHE/css/14e62fd8dc94.css" type="text/css">'
+ out = '<link rel="stylesheet" href="/media/CACHE/css/1c1c0855907b.css" type="text/css">'
self.assertEqual(out, render(template, context))
def test_js_tag(self):
@@ -311,7 +311,7 @@ def test_js_tag(self):
{% endcompress %}
"""
context = { 'MEDIA_URL': settings.COMPRESS_URL }
- out = u'<script type="text/javascript" src="/media/CACHE/js/dc78a3f5af20.js" charset="utf-8"></script>'
+ out = u'<script type="text/javascript" src="/media/CACHE/js/3f33b9146e12.js" charset="utf-8"></script>'
self.assertEqual(out, render(template, context))
def test_nonascii_js_tag(self):
@@ -321,7 +321,7 @@ def test_nonascii_js_tag(self):
{% endcompress %}
"""
context = { 'MEDIA_URL': settings.COMPRESS_URL }
- out = u'<script type="text/javascript" src="/media/CACHE/js/52e783c7eb25.js" charset="utf-8"></script>'
+ out = u'<script type="text/javascript" src="/media/CACHE/js/5d5c0e1cb25f.js" charset="utf-8"></script>'
self.assertEqual(out, render(template, context))
def test_nonascii_latin1_js_tag(self):
@@ -331,7 +331,7 @@ def test_nonascii_latin1_js_tag(self):
{% endcompress %}
"""
context = { 'MEDIA_URL': settings.COMPRESS_URL }
- out = u'<script type="text/javascript" src="/media/CACHE/js/e33dbf2e2457.js" charset="utf-8"></script>'
+ out = u'<script type="text/javascript" src="/media/CACHE/js/40a8e9ffb476.js" charset="utf-8"></script>'
self.assertEqual(out, render(template, context))
def test_compress_tag_with_illegal_arguments(self):
@@ -370,7 +370,7 @@ def test_css_tag_with_storage(self):
{% endcompress %}
"""
context = { 'MEDIA_URL': settings.COMPRESS_URL }
- out = u'<link rel="stylesheet" href="/media/CACHE/css/277b26db9a98.css.gz" type="text/css">'
+ out = u'<link rel="stylesheet" href="/media/CACHE/css/5b231a62e9a6.css.gz" type="text/css">'
self.assertEqual(out, render(template, context))
@@ -403,8 +403,8 @@ def test_offline(self):
count, result = CompressCommand().compress()
self.assertEqual(2, count)
self.assertEqual([
- u'<link rel="stylesheet" href="/media/CACHE/css/4208e0ded309.css" type="text/css">\n',
- u'<script type="text/javascript" src="/media/CACHE/js/f57529d83f3a.js" charset="utf-8"></script>',
+ u'<link rel="stylesheet" href="/media/CACHE/css/a55e1cf95000.css" type="text/css">\n',
+ u'<script type="text/javascript" src="/media/CACHE/js/bf53fa5b13e2.js" charset="utf-8"></script>',
], result)
def test_offline_with_context(self):
@@ -415,7 +415,7 @@ def test_offline_with_context(self):
count, result = CompressCommand().compress()
self.assertEqual(2, count)
self.assertEqual([
- u'<link rel="stylesheet" href="/media/CACHE/css/777d7c22e67c.css" type="text/css">\n',
- u'<script type="text/javascript" src="/media/CACHE/js/f57529d83f3a.js" charset="utf-8"></script>',
+ u'<link rel="stylesheet" href="/media/CACHE/css/8a2405e029de.css" type="text/css">\n',
+ u'<script type="text/javascript" src="/media/CACHE/js/bf53fa5b13e2.js" charset="utf-8"></script>',
], result)
settings.COMPRESS_OFFLINE_CONTEXT = self._old_offline_context
View
6 docs/changelog.txt
@@ -1,6 +1,12 @@
Changelog
=========
+0.6.2
+-----
+
+- Minor bugfixes that caused the compression not working reliably in
+ development mode (e.g. updated files didn't trigger a new compression).
+
0.6.1
-----
View
2  docs/conf.py
@@ -50,7 +50,7 @@
# The short X.Y version.
version = '0.6'
# The full version, including alpha/beta/rc tags.
-release = '0.6.1'
+release = '0.6.2'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
View
7 docs/installation.txt
@@ -16,10 +16,13 @@ Installation
default behaviour and make adjustements for your website.
* In case you use Django 1.3's staticfiles_ contrib app (or its standalone
- clone django-staticfiles_) you have to add Django Compressor's file finder
- to the ``STATICFILES_FINDERS`` setting::
+ counterpart django-staticfiles_) you have to add Django Compressor's file
+ finder to the ``STATICFILES_FINDERS`` setting, for example with
+ ``django.contrib.staticfiles``::
STATICFILES_FINDERS = (
+ 'django.contrib.staticfiles.finders.FileSystemFinder',
+ 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# other finders..
'compressor.finders.CompressorFinder',
)
View
2  docs/usage.txt
@@ -76,7 +76,7 @@ rendered page, e.g.:
<script type="text/javascript" charset="utf-8">obj.value = "value";</script>
{% endcompress %}
-would be rendered something like:
+would be rendered something like::
<script type="text/javascript" charset="utf-8">
obj = {};
Please sign in to comment.
Something went wrong with that request. Please try again.