Skip to content

Commit ce553bf

Browse files
committed
Merge remote-tracking branch 'living180/cache_panel_work'
* living180/cache_panel_work: Re-architect cache call recording Add a .ready() method to the panel API Use request toolbar for cache integration tests Allow integration tests to access the toolbar Add dependency on asgiref
2 parents 4f1e553 + 4b77ec7 commit ce553bf

File tree

8 files changed

+206
-204
lines changed

8 files changed

+206
-204
lines changed

debug_toolbar/apps.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ class DebugToolbarConfig(AppConfig):
1717
def ready(self):
1818
from debug_toolbar.toolbar import DebugToolbar
1919

20-
# Import the panels when the app is ready. This allows panels
21-
# like CachePanel to enable the instrumentation immediately.
22-
DebugToolbar.get_panel_classes()
20+
# Import the panels when the app is ready and call their ready() methods. This
21+
# allows panels like CachePanel to enable their instrumentation immediately.
22+
for cls in DebugToolbar.get_panel_classes():
23+
cls.ready()
2324

2425

2526
def check_template_config(config):

debug_toolbar/panels/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,19 @@ def scripts(self):
114114
"""
115115
return []
116116

117+
# Panel early initialization
118+
119+
@classmethod
120+
def ready(cls):
121+
"""
122+
Perform early initialization for the panel.
123+
124+
This should only include initialization or instrumentation that needs to
125+
be done unconditionally for the panel regardless of whether it is
126+
enabled for a particular request. It should be idempotent.
127+
"""
128+
pass
129+
117130
# URLs for panel-specific views
118131

119132
@classmethod

0 commit comments

Comments
 (0)