Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'release/1.1.1'

  • Loading branch information...
commit 89b734fd24c9e172949cac6df29ea591a95f8aa3 2 parents f226274 + d683e30
@jezdez jezdez authored
View
2  compressor/__init__.py
@@ -1,2 +1,2 @@
# following PEP 386, versiontools will pick it up
-__version__ = (1, 1, 0, "final", 0)
+__version__ = (1, 1, 1, "final", 0)
View
24 compressor/base.py
@@ -1,8 +1,10 @@
from __future__ import with_statement
import os
import codecs
+import urllib
from django.core.files.base import ContentFile
+from django.core.files.storage import get_storage_class
from django.template import Context
from django.template.loader import render_to_string
from django.utils.encoding import smart_unicode
@@ -12,10 +14,10 @@
from compressor.conf import settings
from compressor.exceptions import CompressorError, UncompressableFileError
from compressor.filters import CompilerFilter
-from compressor.storage import default_storage
+from compressor.storage import default_storage, compressor_file_storage
from compressor.signals import post_compress
from compressor.utils import get_class, staticfiles
-from compressor.utils.decorators import cached_property, memoize
+from compressor.utils.decorators import cached_property
# Some constants for nicer handling.
SOURCE_HUNK, SOURCE_FILE = 'inline', 'file'
@@ -66,13 +68,17 @@ def get_filepath(self, content):
return os.path.join(self.output_dir, self.output_prefix, filename)
def get_filename(self, basename):
- # first try to find it with staticfiles (in debug mode)
filename = None
+ # first try finding the file in the root
if self.storage.exists(basename):
- filename = self.storage.path(basename)
- # secondly try finding the file in the root
+ try:
+ filename = self.storage.path(basename)
+ except NotImplementedError:
+ # remote storages don't implement path, access the file locally
+ filename = compressor_file_storage.path(basename)
+ # secondly try to find it with staticfiles (in debug mode)
elif self.finders:
- filename = self.finders.find(basename)
+ filename = self.finders.find(urllib.url2pathname(basename))
if filename:
return filename
# or just raise an exception as the last resort
@@ -113,7 +119,6 @@ def cachekey(self):
return get_hexdigest(''.join(
[self.content] + self.mtimes).encode(self.charset), 12)
- @memoize
def hunks(self, mode='file', forced=False):
"""
The heart of content parsing, iterates of the
@@ -151,7 +156,6 @@ def hunks(self, mode='file', forced=False):
else:
yield mode, self.parser.elem_str(elem)
- @memoize
def filtered_output(self, content):
"""
Passes the concatenated content to the 'output' methods
@@ -159,7 +163,6 @@ def filtered_output(self, content):
"""
return self.filter(content, method=METHOD_OUTPUT)
- @memoize
def filtered_input(self, mode='file', forced=False):
"""
Passes each hunk (file or code) to the 'input' methods
@@ -261,6 +264,7 @@ def render_output(self, mode, context=None):
final_context.update(self.context)
final_context.update(context)
final_context.update(self.extra_context)
- post_compress.send(sender='django-compressor', type=self.type, mode=mode, context=final_context)
+ post_compress.send(sender='django-compressor', type=self.type,
+ mode=mode, context=final_context)
return render_to_string("compressor/%s_%s.html" %
(self.type, mode), final_context)
View
2  compressor/cache.py
@@ -59,7 +59,7 @@ def get_offline_cachekey(source):
def get_offline_manifest_filename():
output_dir = settings.COMPRESS_OUTPUT_DIR.strip('/')
- return os.path.join(output_dir, 'manifest.json')
+ return os.path.join(output_dir, settings.COMPRESS_OFFLINE_MANIFEST)
def get_offline_manifest():
View
2  compressor/conf.py
@@ -60,6 +60,8 @@ class CompressorConf(AppConf):
OFFLINE_TIMEOUT = 60 * 60 * 24 * 365 # 1 year
# The context to be used when compressing the files "offline"
OFFLINE_CONTEXT = {}
+ # The name of the manifest file (e.g. filename.ext)
+ OFFLINE_MANIFEST = 'manifest.json'
class Meta:
prefix = 'compress'
View
2  compressor/filters/yui.py
@@ -3,7 +3,7 @@
class YUICompressorFilter(CompilerFilter):
- command = "{binary} {args}"
+ command = "java -jar {binary} {args}"
def __init__(self, *args, **kwargs):
super(YUICompressorFilter, self).__init__(*args, **kwargs)
View
1  compressor/management/commands/compress.py
@@ -13,6 +13,7 @@
from django.template import Context, Template, TemplateDoesNotExist, TemplateSyntaxError
from django.utils.datastructures import SortedDict
from django.utils.importlib import import_module
+from django.template.loader import get_template
from django.template.loader_tags import ExtendsNode, BlockNode, BLOCK_CONTEXT_KEY
try:
View
6 compressor/storage.py
@@ -3,7 +3,7 @@
from datetime import datetime
from django.core.files.storage import FileSystemStorage, get_storage_class
-from django.utils.functional import LazyObject
+from django.utils.functional import LazyObject, SimpleLazyObject
from compressor.conf import settings
@@ -42,6 +42,10 @@ def get_available_name(self, name):
return name
+compressor_file_storage = SimpleLazyObject(
+ lambda: get_storage_class('compressor.storage.CompressorFileStorage')())
+
+
class GzipCompressorFileStorage(CompressorFileStorage):
"""
The standard compressor file system storage that gzips storage files
View
28 compressor/utils/decorators.py
@@ -1,31 +1,3 @@
-import functools
-
-class memoize(object):
-
- def __init__ (self, func):
- self.func = func
-
- def __call__ (self, *args, **kwargs):
- if (args, str(kwargs)) in self.__dict__:
- value = self.__dict__[args, str(kwargs)]
- else:
- value = self.func(*args, **kwargs)
- self.__dict__[args, str(kwargs)] = value
- return value
-
- def __repr__(self):
- """
- Return the function's docstring.
- """
- return self.func.__doc__ or ''
-
- def __get__(self, obj, objtype):
- """
- Support instance methods.
- """
- return functools.partial(self.__call__, obj)
-
-
class cached_property(object):
"""Property descriptor that caches the return value
of the get function.
View
23 docs/changelog.txt
@@ -1,6 +1,29 @@
Changelog
=========
+v1.1.1
+------
+
+- Fixed a stupid ImportError bug introduced in 1.1.
+
+- Fixed Jinja2 docs of since ``JINJA2_EXTENSIONS`` expects
+ a class, not a module.
+
+- Fixed a Windows bug with regard to file resolving with
+ staticfiles finders.
+
+- Stopped a potential memory leak when memoizing the rendered
+ output.
+
+- Fixed the integration between staticfiles (e.g. in Django <= 1.3.1)
+ and compressor which prevents the collectstatic management command
+ to work.
+
+ .. warning::
+
+ Make sure to **remove** the ``path`` method of your custom
+ :ref:`remote storage <remote_storages>` class!
+
v1.1
----
View
2  docs/conf.py
@@ -50,7 +50,7 @@
# The short X.Y version.
version = '1.1'
# The full version, including alpha/beta/rc tags.
-release = '1.1'
+release = '1.1.1'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
View
2  docs/jinja2.txt
@@ -32,7 +32,7 @@ only requires to add extension to ``JINJA2_EXTENSIONS`` at main settings
module::
JINJA2_EXTENSIONS = [
- 'compressor.contrib.jinja2ext',
+ 'compressor.contrib.jinja2ext.CompressorExtension',
]
And that's it - our extension is loaded and ready to be used.
View
3  docs/remote-storages.txt
@@ -68,9 +68,6 @@ integrated.
self.local_storage._save(name, content)
return name
- def path(self, name):
- return self.local_storage.path(name)
-
#. Set your :ref:`COMPRESS_STORAGE <compress_storage>` and STATICFILES_STORAGE_
settings to the dotted path of your custom cached storage backend, e.g.
``'mysite.storage.CachedS3BotoStorage'``.
View
10 docs/settings.txt
@@ -385,3 +385,13 @@ the contents of ``{% compress %}`` template tags and saving the result in the
offline cache.
If available, the ``STATIC_URL`` setting is also added to the context.
+
+.. _compress_offline_manifest:
+
+COMPRESS_OFFLINE_MANIFEST
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+:Default: ``manifest.json``
+
+The name of the file to be used for saving the names of the files compressed
+offline.
Please sign in to comment.
Something went wrong with that request. Please try again.