diff options
| author | Jannis Leidel | 2013-12-09 19:06:09 +0100 |
|---|---|---|
| committer | Jannis Leidel | 2013-12-09 19:06:09 +0100 |
| commit | ebc16cb2a5c9098d91ca3033626808f73e58afad (patch) | |
| tree | 1c82dbccdd740abb9bb2482a91e21c47a4a87a08 /debug_toolbar/panels/staticfiles.py | |
| parent | 7a04ec6c4f808f59d9f689f72efb182640308494 (diff) | |
| download | django-debug-toolbar-ebc16cb2a5c9098d91ca3033626808f73e58afad.tar.bz2 | |
Use enable_instrumentation/disable_instrumentation instead of module level monkey patching.
Diffstat (limited to 'debug_toolbar/panels/staticfiles.py')
| -rw-r--r-- | debug_toolbar/panels/staticfiles.py | 11 |
1 files changed, 8 insertions, 3 deletions
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: |
