comparison sat_pubsub/tap.py @ 321:c7fe09894952

privilege: better handling of main message 'to' attribute (i.e. privileged entity's server)
author Goffi <goffi@goffi.org>
date Tue, 05 Jan 2016 22:16:37 +0100
parents 5d7c3787672e
children 8496af26be45
comparison
equal deleted inserted replaced
320:29c2553ef863 321:c7fe09894952
57 57
58 from wokkel.component import Component 58 from wokkel.component import Component
59 from wokkel.disco import DiscoHandler 59 from wokkel.disco import DiscoHandler
60 from wokkel.generic import FallbackHandler, VersionHandler 60 from wokkel.generic import FallbackHandler, VersionHandler
61 from wokkel.iwokkel import IPubSubResource 61 from wokkel.iwokkel import IPubSubResource
62 from wokkel import pubsub, rsm, mam as wokkel_mam 62 from wokkel import pubsub, rsm, mam
63 63
64 from sat_pubsub import __version__, const, mam 64 from sat_pubsub import __version__
65 from sat_pubsub import const
66 from sat_pubsub import mam as pubsub_mam
65 from sat_pubsub.backend import BackendService 67 from sat_pubsub.backend import BackendService
66 from sat_pubsub.privilege import PrivilegesHandler 68 from sat_pubsub.privilege import PrivilegesHandler
67 from sat_pubsub.delegation import DelegationsHandler 69 from sat_pubsub.delegation import DelegationsHandler
68 70
69 71
136 138
137 FallbackHandler().setHandlerParent(cs) 139 FallbackHandler().setHandlerParent(cs)
138 VersionHandler(u'SàT Pubsub', __version__).setHandlerParent(cs) 140 VersionHandler(u'SàT Pubsub', __version__).setHandlerParent(cs)
139 DiscoHandler().setHandlerParent(cs) 141 DiscoHandler().setHandlerParent(cs)
140 142
141 ph = PrivilegesHandler() 143 ph = PrivilegesHandler(config['jid'])
142 ph.setHandlerParent(cs) 144 ph.setHandlerParent(cs)
143 bs.privilege = ph 145 bs.privilege = ph
144
145 dh = DelegationsHandler()
146 dh.setHandlerParent(cs)
147 bs.delegation = dh
148 146
149 resource = IPubSubResource(bs) 147 resource = IPubSubResource(bs)
150 resource.hideNodes = config["hide-nodes"] 148 resource.hideNodes = config["hide-nodes"]
151 resource.serviceJID = config["jid"] 149 resource.serviceJID = config["jid"]
152 150
153 ps = (rsm if const.FLAG_ENABLE_RSM else pubsub).PubSubService(resource) 151 ps = (rsm if const.FLAG_ENABLE_RSM else pubsub).PubSubService(resource)
154 ps.setHandlerParent(cs) 152 ps.setHandlerParent(cs)
155 resource.pubsubService = ps 153 resource.pubsubService = ps
156 154
157 if const.FLAG_ENABLE_MAM: 155 if const.FLAG_ENABLE_MAM:
158 mam_resource = mam.MAMResource(bs) 156 mam_resource = pubsub_mam.MAMResource(bs)
159 mam_s = wokkel_mam.MAMService(mam_resource) 157 mam_s = mam.MAMService(mam_resource)
160 mam_s.setHandlerParent(cs) 158 mam_s.setHandlerParent(cs)
161 159
160 # XXX: delegation must be instancied at the end,
161 # because it does some MonkeyPatching on handlers
162 dh = DelegationsHandler()
163 dh.setHandlerParent(cs)
164 bs.delegation = dh
165
162 return s 166 return s