From ebc16cb2a5c9098d91ca3033626808f73e58afad Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 9 Dec 2013 19:06:09 +0100 Subject: Use enable_instrumentation/disable_instrumentation instead of module level monkey patching. --- debug_toolbar/panels/staticfiles.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'debug_toolbar/panels/staticfiles.py') diff --git a/debug_toolbar/panels/staticfiles.py b/debug_toolbar/panels/staticfiles.py index 0ecba51..9813609 100644 --- a/debug_toolbar/panels/staticfiles.py +++ b/debug_toolbar/panels/staticfiles.py @@ -31,7 +31,7 @@ class StaticFile(object): def __init__(self, path): self.path = path - def __unicode__(self): + def __str__(self): return self.path def real_path(self): @@ -75,8 +75,6 @@ class DebugConfiguredStorage(LazyObject): self._wrapped = DebugStaticFilesStorage(collector) -storage.staticfiles_storage = staticfiles.staticfiles_storage = DebugConfiguredStorage() - class StaticFilesPanel(panels.Panel): """ @@ -95,6 +93,13 @@ class StaticFilesPanel(panels.Panel): self.num_found = 0 self._paths = {} + def enable_instrumentation(self): + self._unpatched_staticfiles_storage = storage.staticfiles_storage + storage.staticfiles_storage = staticfiles.staticfiles_storage = DebugConfiguredStorage() + + def disable_instrumentation(self): + storage.staticfiles_storage = staticfiles.staticfiles_storage = self._unpatched_staticfiles_storage + @property def has_content(self): if "django.contrib.staticfiles" not in settings.INSTALLED_APPS: -- cgit v1.2.3