# HG changeset patch # User Laurent Peuch # Date 1573742435 -3600 # Node ID 682d0790997f8edf609b3a95d78b9945595c237c # Parent 771c99f16780cf3820ca87db74e5d3b776ac3b58 [debug-toolbar] add registry panel Closes #17219866 diff -r 771c99f16780 -r 682d0790997f cubicweb/debug.py --- a/cubicweb/debug.py Thu Nov 14 01:01:00 2019 +0100 +++ b/cubicweb/debug.py Thu Nov 14 15:40:35 2019 +0100 @@ -25,6 +25,7 @@ "controller": [], "rql": [], "sql": [], + "vreg": [], } diff -r 771c99f16780 -r 682d0790997f cubicweb/pyramid/bwcompat.py --- a/cubicweb/pyramid/bwcompat.py Thu Nov 14 01:01:00 2019 +0100 +++ b/cubicweb/pyramid/bwcompat.py Thu Nov 14 15:40:35 2019 +0100 @@ -93,6 +93,9 @@ ctrlid, req.path, controller, inspect.getsourcefile(controller.__class__), inspect.getsourcelines(controller.__class__)[1]) + emit_to_debug_channel("vreg", { + "vreg": vreg, + }) emit_to_debug_channel("controller", { "kind": ctrlid, "request": req, diff -r 771c99f16780 -r 682d0790997f cubicweb/pyramid/debug_toolbar_templates/registry.dbtmako --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cubicweb/pyramid/debug_toolbar_templates/registry.dbtmako Thu Nov 14 15:40:35 2019 +0100 @@ -0,0 +1,93 @@ +% if vreg: + +
+
+
+ +
+ +
+ % for category, data in sorted(vreg.items(), key=lambda x: x[0]): +
+ +

${category.title()}

+ + % for key, values in sorted(data.items(), key=lambda x: x[0]): + + + + + % endfor +
${key} +
    + % for value in values: +
  • + % if isinstance(value, type): + ${value.__module__}.${value.__name__} + % else: + ${value} + % endif + +
      + % if hasattr(value, "cw_etype"): +
    • regid: '${value.cw_etype}'
    • + % elif hasattr(value, "__regid__"): +
    • regid: '${value.__regid__}'
    • + % endif + + % if hasattr(value, "__select__"): +
    • select: '${value.__select__}'
    • + % if hasattr(value.__select__, "func_name"): +
    • select name: '${value.__select__.func_name}'
    • + % endif + % if hasattr(value.__select__, "score"): +
    • select score: '${value.__select__.score}'
    • + % endif + % endif + +
    • registries: ${value.__registries__}
    • + + % if hasattr(value, "rest_attr"): +
    • rest_attr: '${value.rest_attr}'
    • + % endif + + % if hasattr(value, "fetch_attrs"): +
    • fetch_attrs: '${value.fetch_attrs}'
    • + % endif + + % if hasattr(value, "cw_skip_copy_for"): +
    • cw_skip_copy_for: '${value.cw_skip_copy_for}'
    • + % endif + + % if hasattr(value, "e_schema"): +
    • e_schema: '${value.e_schema}'
    • + % endif +
    +
  • + % endfor +
+
+
+ % endfor +
+
+
+ +% else: +

No registry store got collected, is it a bug?

+% endif + + diff -r 771c99f16780 -r 682d0790997f cubicweb/pyramid/debugtoolbar_panels.py --- a/cubicweb/pyramid/debugtoolbar_panels.py Thu Nov 14 01:01:00 2019 +0100 +++ b/cubicweb/pyramid/debugtoolbar_panels.py Thu Nov 14 15:40:35 2019 +0100 @@ -54,6 +54,29 @@ unsubscribe_to_debug_channel("controller", self.collect_controller) +class RegistryDebugPanel(DebugPanel): + """ + CubicWeb registry content and decisions debug panel + """ + + name = 'Registry' + title = 'Registry Store' + nav_title = 'Registry Store' + + has_content = True + template = 'cubicweb.pyramid:debug_toolbar_templates/registry.dbtmako' + + def __init__(self, request): + self.data = {'vreg': None} + subscribe_to_debug_channel("vreg", self.collect_vreg) + + def collect_vreg(self, message): + self.data["vreg"] = message["vreg"] + + def process_response(self, response): + unsubscribe_to_debug_channel("vreg", self.collect_vreg) + + class RQLDebugPanel(DebugPanel): """ CubicWeb RQL debug panel @@ -167,5 +190,6 @@ def includeme(config): config.add_debugtoolbar_panel(CubicWebDebugPanel) + config.add_debugtoolbar_panel(RegistryDebugPanel) config.add_debugtoolbar_panel(RQLDebugPanel) config.add_debugtoolbar_panel(SQLDebugPanel)