From 9c6a371aaafc11d51f124ccb9d7334fe11411eeb Mon Sep 17 00:00:00 2001 From: Shabda Raaj Date: Wed, 4 Aug 2010 01:41:08 +1000 Subject: [PATCH] compress.filters.FilterBase alllows setting the verbosity while object creation. Since I specify this in settings, I do not have a control over setting the verbosity. This change allow settings the verbosity from settings. --- compressor/conf/settings.py | 3 +++ compressor/filters/__init__.py | 4 +++- tests/core/tests.py | 7 +++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/compressor/conf/settings.py b/compressor/conf/settings.py index dc0c42b..b4d1891 100644 --- a/compressor/conf/settings.py +++ b/compressor/conf/settings.py @@ -33,3 +33,6 @@ MTIME_DELAY = getattr(settings, 'COMPRESS_MTIME_DELAY', None) # the backend to use when parsing the JavaScript or Stylesheet files PARSER = getattr(settings, 'COMPRESS_PARSER', 'compressor.parser.BeautifulSoupParser') + +# Allows changing verbosity from the settings. +VERBOSE = getattr(settings, "COMPRESS_VERBOSE", False) diff --git a/compressor/filters/__init__.py b/compressor/filters/__init__.py index f81eb90..adc7c69 100644 --- a/compressor/filters/__init__.py +++ b/compressor/filters/__init__.py @@ -1,13 +1,15 @@ from compressor.exceptions import FilterError from compressor.utils import get_class, get_mod_func +from compressor.conf import settings class FilterBase(object): def __init__(self, content, filter_type=None, verbose=0): self.type = filter_type self.content = content - self.verbose = verbose + self.verbose = verbose or settings.VERBOSE def input(self, **kwargs): raise NotImplementedError + def output(self, **kwargs): raise NotImplementedError diff --git a/tests/core/tests.py b/tests/core/tests.py index cf25c5f..ca4a3b2 100644 --- a/tests/core/tests.py +++ b/tests/core/tests.py @@ -357,3 +357,10 @@ class StorageTestCase(TestCase): context = { 'MEDIA_URL': settings.MEDIA_URL } out = u'' self.assertEqual(out, render(template, context)) + + +class VerboseTestCase(CompressorTestCase): + + def setUp(self): + super(VerboseTestCase, self).setUp() + setattr(settings, "COMPRESS_VERBOSE", True)