Mercurial > libervia-pubsub
comparison idavoll/tap.py @ 222:698af5d720ad
Reshape Idavoll as a PubSubResource.
PubSubResource is Wokkel's newer interface for building (parts of) XMPP
publish-subscribe services and replaces the old interface of PubSubService. It
is more flexible for adding new protocol, allows for node-as-code (providing a
specific backend per node), and permits accepting requests for different
entities (virtual hosts or PEP-like settings).
This moves over the current backend to use the new interface, so new code for
previously unsupported protocol can be added down the line.
author | Ralph Meijer <ralphm@ik.nu> |
---|---|
date | Sat, 16 Oct 2010 21:03:38 +0200 |
parents | 479fc959af0e |
children | 0eafdced5f24 |
comparison
equal
deleted
inserted
replaced
221:a430976f2977 | 222:698af5d720ad |
---|---|
6 from twisted.words.protocols.jabber.jid import JID | 6 from twisted.words.protocols.jabber.jid import JID |
7 | 7 |
8 from wokkel.component import Component | 8 from wokkel.component import Component |
9 from wokkel.disco import DiscoHandler | 9 from wokkel.disco import DiscoHandler |
10 from wokkel.generic import FallbackHandler, VersionHandler | 10 from wokkel.generic import FallbackHandler, VersionHandler |
11 from wokkel.iwokkel import IPubSubService | 11 from wokkel.iwokkel import IPubSubResource |
12 from wokkel.pubsub import PubSubService | |
12 | 13 |
13 from idavoll import __version__ | 14 from idavoll import __version__ |
14 from idavoll.backend import BackendService | 15 from idavoll.backend import BackendService |
15 | 16 |
16 class Options(usage.Options): | 17 class Options(usage.Options): |
35 def postOptions(self): | 36 def postOptions(self): |
36 if self['backend'] not in ['pgsql', 'memory']: | 37 if self['backend'] not in ['pgsql', 'memory']: |
37 raise usage.UsageError, "Unknown backend!" | 38 raise usage.UsageError, "Unknown backend!" |
38 | 39 |
39 self['jid'] = JID(self['jid']) | 40 self['jid'] = JID(self['jid']) |
41 | |
42 | |
40 | 43 |
41 def makeService(config): | 44 def makeService(config): |
42 s = service.MultiService() | 45 s = service.MultiService() |
43 | 46 |
44 # Create backend service with storage | 47 # Create backend service with storage |
78 | 81 |
79 FallbackHandler().setHandlerParent(cs) | 82 FallbackHandler().setHandlerParent(cs) |
80 VersionHandler('Idavoll', __version__).setHandlerParent(cs) | 83 VersionHandler('Idavoll', __version__).setHandlerParent(cs) |
81 DiscoHandler().setHandlerParent(cs) | 84 DiscoHandler().setHandlerParent(cs) |
82 | 85 |
83 ps = IPubSubService(bs) | 86 resource = IPubSubResource(bs) |
87 resource.hideNodes = config["hide-nodes"] | |
88 resource.serviceJID = config["jid"] | |
89 | |
90 ps = PubSubService(resource) | |
84 ps.setHandlerParent(cs) | 91 ps.setHandlerParent(cs) |
85 ps.hideNodes = config["hide-nodes"] | 92 resource.pubsubService = ps |
86 ps.serviceJID = config["jid"] | |
87 | 93 |
88 return s | 94 return s |