Skip to content

Commit ebc16cb

Browse files
committed
Use enable_instrumentation/disable_instrumentation instead of module level monkey patching.
1 parent 7a04ec6 commit ebc16cb

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

debug_toolbar/panels/staticfiles.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class StaticFile(object):
3131
def __init__(self, path):
3232
self.path = path
3333

34-
def __unicode__(self):
34+
def __str__(self):
3535
return self.path
3636

3737
def real_path(self):
@@ -75,8 +75,6 @@ def url(self, path):
7575

7676
self._wrapped = DebugStaticFilesStorage(collector)
7777

78-
storage.staticfiles_storage = staticfiles.staticfiles_storage = DebugConfiguredStorage()
79-
8078

8179
class StaticFilesPanel(panels.Panel):
8280
"""
@@ -95,6 +93,13 @@ def __init__(self, *args, **kwargs):
9593
self.num_found = 0
9694
self._paths = {}
9795

96+
def enable_instrumentation(self):
97+
self._unpatched_staticfiles_storage = storage.staticfiles_storage
98+
storage.staticfiles_storage = staticfiles.staticfiles_storage = DebugConfiguredStorage()
99+
100+
def disable_instrumentation(self):
101+
storage.staticfiles_storage = staticfiles.staticfiles_storage = self._unpatched_staticfiles_storage
102+
98103
@property
99104
def has_content(self):
100105
if "django.contrib.staticfiles" not in settings.INSTALLED_APPS:

0 commit comments

Comments
 (0)