diff libervia/backend/core/xmpp.py @ 4333:e94799a0908f

core (main): Let plugins have several handlers + various improvements: `get_handler` can now return several handlers, which is notably useful for component with several included services. Various improvements such move to `async` method, docstring/type hints update, and slight improvment of SatXMPPComponent. rel 453
author Goffi <goffi@goffi.org>
date Tue, 03 Dec 2024 00:11:00 +0100
parents 94e0968987cd
children 17fa953c8cd7
line wrap: on
line diff
--- a/libervia/backend/core/xmpp.py	Sat Jul 13 18:28:28 2024 +0200
+++ b/libervia/backend/core/xmpp.py	Tue Dec 03 00:11:00 2024 +0100
@@ -18,6 +18,7 @@
 
 import asyncio
 import calendar
+from collections.abc import Iterable
 import copy
 from functools import partial
 import mimetypes
@@ -146,8 +147,12 @@
         self.plugins = plugins = self._get_plugins_list()
         for plugin in plugins:
             # we check if plugin handle client mode
-            if plugin.is_handler:
-                plugin.get_handler(self).setHandlerParent(self)
+            if plugin.has_handlers:
+                handlers = plugin.get_handler(self)
+                if not isinstance(handlers, Iterable):
+                    handlers = [handlers]
+                for handler in handlers:
+                    handler.setHandlerParent(self)
 
             # profile_connecting/profile_connected methods handling
 
@@ -1085,7 +1090,7 @@
 
 
 @implementer(iwokkel.IDisco)
-class SatXMPPComponent(SatXMPPEntity, component.Component):
+class SatXMPPComponent(SatXMPPEntity, core_types.SatXMPPComponent, component.Component):
     """XMPP component
 
     This component are similar but not identical to clients.