comparison twisted/plugins/pubsub.py @ 417:412d26a9b2c2

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 ccb2a22ea0fc
children 89736353f6be
comparison
equal deleted inserted replaced
416:ee722faa3e93 417:412d26a9b2c2
57 from twisted.application import service 57 from twisted.application import service
58 from twisted.python import usage, log 58 from twisted.python import usage, log
59 from twisted.words.protocols.jabber.jid import JID 59 from twisted.words.protocols.jabber.jid import JID
60 from twisted.plugin import IPlugin 60 from twisted.plugin import IPlugin
61 61
62 from wokkel.component import Component
63 from wokkel.disco import DiscoHandler
64 from wokkel.generic import FallbackHandler, VersionHandler
65 from wokkel.iwokkel import IPubSubResource
66 from wokkel import data_form
67 from wokkel import pubsub
68 from wokkel import rsm
69 from wokkel import mam
70 from zope.interface import implementer 62 from zope.interface import implementer
71 63
72 from sat_pubsub import const
73 from sat_pubsub import mam as pubsub_mam
74 from sat_pubsub import pubsub_admin
75 from sat_pubsub.backend import BackendService, ExtraDiscoHandler
76 from sat_pubsub.schema import SchemaHandler
77 from sat_pubsub.privilege import PrivilegesHandler
78 from sat_pubsub.delegation import DelegationsHandler
79 from os.path import expanduser, realpath 64 from os.path import expanduser, realpath
80 import configparser 65 import configparser
81 66
82 67
83 def coerceListType(value): 68 def coerceListType(value):
176 tapname = "sat-pubsub" 161 tapname = "sat-pubsub"
177 description = "Salut à Toi Publish-Subscribe Service Component" 162 description = "Salut à Toi Publish-Subscribe Service Component"
178 options = Options 163 options = Options
179 164
180 def makeService(self, config): 165 def makeService(self, config):
166 from wokkel.component import Component
167 from wokkel.disco import DiscoHandler
168 from wokkel.generic import FallbackHandler, VersionHandler
169 from wokkel.iwokkel import IPubSubResource
170 from wokkel import data_form
171 from wokkel import pubsub
172 from wokkel import rsm
173 from wokkel import mam
174 from sat_pubsub import const
175 from sat_pubsub import mam as pubsub_mam
176 from sat_pubsub import pubsub_admin
177 from sat_pubsub.backend import BackendService, ExtraDiscoHandler
178 from sat_pubsub.schema import SchemaHandler
179 from sat_pubsub.privilege import PrivilegesHandler
180 from sat_pubsub.delegation import DelegationsHandler
181
181 if not config['jid'] or not config['xmpp_pwd']: 182 if not config['jid'] or not config['xmpp_pwd']:
182 raise usage.UsageError("You must specify jid and xmpp_pwd") 183 raise usage.UsageError("You must specify jid and xmpp_pwd")
183 s = service.MultiService() 184 s = service.MultiService()
184 185
185 # Create backend service with storage 186 # Create backend service with storage