cubicweb/cwvreg.py
changeset 12768 7d2c61d40fe9
parent 12567 26744ad37953
child 12785 a9025212ce0c
--- a/cubicweb/cwvreg.py	Wed Nov 20 20:46:45 2019 +0100
+++ b/cubicweb/cwvreg.py	Thu Sep 12 05:59:10 2019 +0200
@@ -33,6 +33,7 @@
 from yams.constraints import BASE_CONVERTERS
 
 from cubicweb import _
+from cubicweb.debug import emit_to_debug_channel
 from cubicweb import (CW_SOFTWARE_ROOT, ETYPE_NAME_MAP, CW_EVENT_MANAGER,
                       onevent, Binary, UnknownProperty, UnknownEid)
 from cubicweb.predicates import appobject_selectable, _reset_is_instance_cache
@@ -72,6 +73,16 @@
         super(CWRegistry, self).__init__(True)
         self.vreg = vreg
 
+    def _select_best(self, objects, *args, **kwargs):
+        """
+        Overwrite version of Registry._select_best to emit debug information.
+        """
+        def emit_registry_debug_information(debug_registry_select_best):
+            emit_to_debug_channel("registry_decisions", debug_registry_select_best)
+
+        kwargs["debug_callback"] = emit_registry_debug_information
+        return super()._select_best(objects, *args, **kwargs)
+
     @property
     def schema(self):
         """The :py:class:`cubicweb.schema.CubicWebSchema`