Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
merge CACHE_BACKEND feature from django_compressor
Browse files Browse the repository at this point in the history
  • Loading branch information
wil committed Oct 29, 2010
1 parent 5e9e7d5 commit a4abd71
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ If this seems a little hacky, it's because I wanted to make it easy to use whate
converted to absolute URLs while being processed. Any local absolute urls (those
starting with a '/') are left alone.

``COMPRESS_CACHE_BACKEND`` default: ``CACHE_BACKEND``
The backend to use for caching, in case you want to use a different cache
backend for compressor. Defaults to the ``CACHE_BACKEND`` setting.



Notes
*****
Expand Down
4 changes: 4 additions & 0 deletions compressor/cache.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from django.core.cache import get_cache
from compressor.conf import settings

cache = get_cache(settings.CACHE_BACKEND)
2 changes: 2 additions & 0 deletions compressor/conf/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@

if ABSOLUTE_CSS_URLS and 'compressor.filters.css_default.CssAbsoluteFilter' not in COMPRESS_CSS_FILTERS:
COMPRESS_CSS_FILTERS.insert(0, 'compressor.filters.css_default.CssAbsoluteFilter')

CACHE_BACKEND = getattr(settings, 'COMPRESS_CACHE_BACKEND', settings.CACHE_BACKEND)
2 changes: 1 addition & 1 deletion compressor/templatetags/compress.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django import template
from django.core.cache import cache

try:
from django.contrib.sites.models import Site
Expand All @@ -8,6 +7,7 @@
DOMAIN = ''

from compressor import CssCompressor, JsCompressor
from compressor.cache import cache
from compressor.conf import settings
from time import sleep

Expand Down
7 changes: 7 additions & 0 deletions compressor/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from compressor import CssCompressor, JsCompressor, UncompressableFileError
from compressor.conf import settings
from compressor.utils import get_file_hash
from django.core.cache.backends import dummy

class BaseTestCase(TestCase):

Expand All @@ -31,6 +32,7 @@ def setUp(self):
'arguments': '*.ccss'
},
}
settings.CACHE_BACKEND = "dummy://"


class CompressorTestCase(BaseTestCase):
Expand Down Expand Up @@ -254,3 +256,8 @@ def test_js_tag(self):
out = u'<script type="text/javascript" src="/media/CACHE/js/3f33b9146e12.js"></script>'
self.assertEqual(out, self.render(template, context))


class CacheBackendTestCase(BaseTestCase):
def test_correct_backend(self):
from compressor.cache import cache
self.assertEqual(cache.__class__, dummy.CacheClass)

0 comments on commit a4abd71

Please sign in to comment.