changeset 417:412d26a9b2c2 default tip

import sat/wokkel modules only when making service: when importing some sat/wokkel module, a reactor is installed. This can cause trouble when using sat_pubsub along with other twisted plugin installing a specific reactor (which is the case for SàT backend and Libervia). This patch works around it by importing those modules only when making the service.
author Goffi <goffi@goffi.org>
date Tue, 08 Oct 2019 12:04:13 +0200
parents ee722faa3e93
children
files sat_pubsub/pubsub_admin.py twisted/plugins/pubsub.py
diffstat 2 files changed, 16 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/sat_pubsub/pubsub_admin.py	Sun Aug 25 12:26:35 2019 +0200
+++ b/sat_pubsub/pubsub_admin.py	Tue Oct 08 12:04:13 2019 +0200
@@ -110,7 +110,6 @@
                     pep=pep,
                     recipient=recipient)
             except (error.Forbidden, error.ItemForbidden):
-                __import__('pudb').set_trace()
                 self.sendError(iq_elt, "forbidden")
                 return
             except Exception as e:
--- a/twisted/plugins/pubsub.py	Sun Aug 25 12:26:35 2019 +0200
+++ b/twisted/plugins/pubsub.py	Tue Oct 08 12:04:13 2019 +0200
@@ -59,23 +59,8 @@
 from twisted.words.protocols.jabber.jid import JID
 from twisted.plugin import IPlugin
 
-from wokkel.component import Component
-from wokkel.disco import DiscoHandler
-from wokkel.generic import FallbackHandler, VersionHandler
-from wokkel.iwokkel import IPubSubResource
-from wokkel import data_form
-from wokkel import pubsub
-from wokkel import rsm
-from wokkel import mam
 from zope.interface import implementer
 
-from sat_pubsub import const
-from sat_pubsub import mam as pubsub_mam
-from sat_pubsub import pubsub_admin
-from sat_pubsub.backend import BackendService, ExtraDiscoHandler
-from sat_pubsub.schema import SchemaHandler
-from sat_pubsub.privilege import PrivilegesHandler
-from sat_pubsub.delegation import DelegationsHandler
 from os.path import expanduser, realpath
 import configparser
 
@@ -178,6 +163,22 @@
     options = Options
 
     def makeService(self, config):
+        from wokkel.component import Component
+        from wokkel.disco import DiscoHandler
+        from wokkel.generic import FallbackHandler, VersionHandler
+        from wokkel.iwokkel import IPubSubResource
+        from wokkel import data_form
+        from wokkel import pubsub
+        from wokkel import rsm
+        from wokkel import mam
+        from sat_pubsub import const
+        from sat_pubsub import mam as pubsub_mam
+        from sat_pubsub import pubsub_admin
+        from sat_pubsub.backend import BackendService, ExtraDiscoHandler
+        from sat_pubsub.schema import SchemaHandler
+        from sat_pubsub.privilege import PrivilegesHandler
+        from sat_pubsub.delegation import DelegationsHandler
+
         if not config['jid'] or not config['xmpp_pwd']:
             raise usage.UsageError("You must specify jid and xmpp_pwd")
         s = service.MultiService()