From bc206765fa4c49856d9f5f0ec1c2a394fd0fda63 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Wed, 22 Nov 2017 11:01:02 +0100 Subject: [PATCH] Appease flake8. --- dbtemplates/admin.py | 2 ++ dbtemplates/loader.py | 4 ++-- dbtemplates/management/commands/sync_templates.py | 2 +- dbtemplates/utils/cache.py | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dbtemplates/admin.py b/dbtemplates/admin.py index 14b35f9..c18f96d 100644 --- a/dbtemplates/admin.py +++ b/dbtemplates/admin.py @@ -49,6 +49,7 @@ class CodeMirrorTextArea(forms.Textarea): """ % dict(media_prefix=settings.DBTEMPLATES_MEDIA_PREFIX, name=name)) return mark_safe(u"".join(result)) + if settings.DBTEMPLATES_USE_CODEMIRROR: TemplateContentTextArea = CodeMirrorTextArea else: @@ -161,4 +162,5 @@ class TemplateAdmin(TemplateModelAdmin): return ", ".join([site.name for site in template.sites.all()]) site_list.short_description = _('sites') + admin.site.register(Template, TemplateAdmin) diff --git a/dbtemplates/loader.py b/dbtemplates/loader.py index c542f7e..015d9a9 100644 --- a/dbtemplates/loader.py +++ b/dbtemplates/loader.py @@ -45,7 +45,7 @@ class Loader(BaseLoader): backend_template = cache.get(cache_key) if backend_template: return backend_template, template_name - except: + except Exception: pass # Not found in cache, move on. @@ -55,7 +55,7 @@ class Loader(BaseLoader): notfound = cache.get(cache_notfound_key) if notfound: raise TemplateDoesNotExist(template_name) - except: + except Exception: raise TemplateDoesNotExist(template_name) # Not marked as not-found, move on... diff --git a/dbtemplates/management/commands/sync_templates.py b/dbtemplates/management/commands/sync_templates.py index 5a93b4f..020313e 100644 --- a/dbtemplates/management/commands/sync_templates.py +++ b/dbtemplates/management/commands/sync_templates.py @@ -60,7 +60,7 @@ class Command(BaseCommand): try: site = Site.objects.get_current() - except: + except Exception: raise CommandError("Please make sure to have the sites contrib " "app installed and setup with a site object") diff --git a/dbtemplates/utils/cache.py b/dbtemplates/utils/cache.py index 1d8b246..98f63f7 100644 --- a/dbtemplates/utils/cache.py +++ b/dbtemplates/utils/cache.py @@ -17,6 +17,7 @@ def get_cache_backend(): signals.request_finished.connect(cache.close) return cache + cache = get_cache_backend()