File tree Expand file tree Collapse file tree 1 file changed +12
-23
lines changed Expand file tree Collapse file tree 1 file changed +12
-23
lines changed Original file line number Diff line number Diff line change 66from debug_toolbar .toolbar .loader import load_panel_classes
77from debug_toolbar .middleware import DebugToolbarMiddleware
88
9- loaded = False
109
11-
12- def is_toolbar (cls ):
13- return (issubclass (cls , DebugToolbarMiddleware ) or
14- DebugToolbarMiddleware in getattr (cls , '__bases__' , ()))
15-
16-
17- def iter_toolbar_middlewares ():
18- global loaded
19- for middleware_path in settings .MIDDLEWARE_CLASSES :
20- try :
21- mod_path , cls_name = middleware_path .rsplit ('.' , 1 )
22- mod = import_module (mod_path )
23- middleware_cls = getattr (mod , cls_name )
24- except (AttributeError , ImportError , ValueError ):
25- continue
26- if is_toolbar (middleware_cls ) and not loaded :
27- # we have a hit!
28- loaded = True
29- yield middleware_cls
30-
31- for middleware_cls in iter_toolbar_middlewares ():
32- load_panel_classes ()
10+ for middleware_path in settings .MIDDLEWARE_CLASSES :
11+ # Replace this with import_by_path in Django >= 1.6.
12+ try :
13+ mod_path , cls_name = middleware_path .rsplit ('.' , 1 )
14+ mod = import_module (mod_path )
15+ middleware_cls = getattr (mod , cls_name )
16+ except (AttributeError , ImportError , ValueError ):
17+ continue
18+
19+ if issubclass (middleware_cls , DebugToolbarMiddleware ):
20+ load_panel_classes ()
21+ break
You can’t perform that action at this time.
0 commit comments