Pārlūkot izejas kodu

Implements a new make target to list registered hooks in an instance

Yann Weber 8 gadus atpakaļ
vecāks
revīzija
71cdb2e75d
2 mainītis faili ar 22 papildinājumiem un 1 dzēšanām
  1. 3
    0
      install/Makefile
  2. 19
    1
      install/lodel_admin.py

+ 3
- 0
install/Makefile Parādīt failu

@@ -7,3 +7,6 @@ dyncode:
7 7
 
8 8
 init_db: dyncode
9 9
 	$(python) -c 'import lodel_admin; lodel_admin.init_all_dbs()'
10
+
11
+list_hooks: dyncode
12
+	$(python) -c 'import lodel_admin; lodel_admin.list_registered_hooks()'

+ 19
- 1
install/lodel_admin.py Parādīt failu

@@ -96,4 +96,22 @@ init_db method: %s"
96 96
             msg %= (ds_name, plugin_name, ds_identifier, e)
97 97
         logger.info("Database initialisation done for %s(%s.%s)" % (
98 98
             ds_name, plugin_name, ds_identifier))
99
-        
99
+
100
+def list_registered_hooks():
101
+    import loader
102
+    loader.start()
103
+    from lodel.plugin.hooks import LodelHook
104
+    hlist = LodelHook.hook_list()
105
+    print("Registered hooks are : ")
106
+    for name in sorted(hlist.keys()):
107
+        print("\t- %s is registered by : " % name)
108
+        for reg_hook in hlist[name]:
109
+            hook, priority = reg_hook
110
+            msg = "\t\t- {modname}.{funname} with priority : {priority}"
111
+            msg = msg.format(
112
+                modname = hook.__module__,
113
+                funname = hook.__name__,
114
+                priority = priority)
115
+            print(msg)
116
+        print("\n")
117
+

Notiek ielāde…
Atcelt
Saglabāt