annotate idavoll/pubsub.py @ 20:eddea65d1032

Added two exceptions: NoInstantNodes and NodeExists. Renamed 'name' attribute of Node to 'id'. Added create_node() method.
author Ralph Meijer <ralphm@ik.nu>
date Wed, 06 Oct 2004 21:05:42 +0000
parents 7937d6fbbe2a
children e01bbbfa8a46
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
1 from twisted.protocols.jabber import component,jid
2
9701df89c534 First take at notifications
Ralph Meijer <ralphm@ik.nu>
parents: 1
diff changeset
2 from twisted.xish import utility, domish
1
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
3 from twisted.python import components
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
4 import backend
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
5 import xmpp_error
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
6
2
9701df89c534 First take at notifications
Ralph Meijer <ralphm@ik.nu>
parents: 1
diff changeset
7 NS_COMPONENT = 'jabber:component:accept'
9701df89c534 First take at notifications
Ralph Meijer <ralphm@ik.nu>
parents: 1
diff changeset
8 NS_PUBSUB = 'http://jabber.org/protocol/pubsub'
9701df89c534 First take at notifications
Ralph Meijer <ralphm@ik.nu>
parents: 1
diff changeset
9 NS_PUBSUB_EVENT = NS_PUBSUB + '#event'
16
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
10 NS_PUBSUB_ERRORS = NS_PUBSUB + '#errors'
2
9701df89c534 First take at notifications
Ralph Meijer <ralphm@ik.nu>
parents: 1
diff changeset
11
1
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
12 IQ_GET = '/iq[@type="get"]'
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
13 IQ_SET = '/iq[@type="set"]'
2
9701df89c534 First take at notifications
Ralph Meijer <ralphm@ik.nu>
parents: 1
diff changeset
14 PUBSUB_ELEMENT = '/pubsub[@xmlns="' + NS_PUBSUB + '"]'
9701df89c534 First take at notifications
Ralph Meijer <ralphm@ik.nu>
parents: 1
diff changeset
15 PUBSUB_GET = IQ_GET + PUBSUB_ELEMENT
9701df89c534 First take at notifications
Ralph Meijer <ralphm@ik.nu>
parents: 1
diff changeset
16 PUBSUB_SET = IQ_SET + PUBSUB_ELEMENT
1
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
17 PUBSUB_CREATE = PUBSUB_SET + '/create'
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
18 PUBSUB_PUBLISH = PUBSUB_SET + '/publish'
16
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
19 PUBSUB_SUBSCRIBE = PUBSUB_SET + '/subscribe'
7
a8cfb31dc50c Implemented fallback for feature-not-implemented.
Ralph Meijer <ralphm@ik.nu>
parents: 4
diff changeset
20 PUBSUB_OPTIONS_GET = PUBSUB_GET + '/options'
a8cfb31dc50c Implemented fallback for feature-not-implemented.
Ralph Meijer <ralphm@ik.nu>
parents: 4
diff changeset
21 PUBSUB_CONFIGURE_GET = PUBSUB_GET + '/configure'
1
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
22
4
ea195dc1732d Allow publication of more than 1 item.
Ralph Meijer <ralphm@ik.nu>
parents: 2
diff changeset
23 error_map = {
ea195dc1732d Allow publication of more than 1 item.
Ralph Meijer <ralphm@ik.nu>
parents: 2
diff changeset
24 backend.NotAuthorized: 'not-authorized',
ea195dc1732d Allow publication of more than 1 item.
Ralph Meijer <ralphm@ik.nu>
parents: 2
diff changeset
25 backend.NodeNotFound: 'item-not-found',
ea195dc1732d Allow publication of more than 1 item.
Ralph Meijer <ralphm@ik.nu>
parents: 2
diff changeset
26 backend.NoPayloadAllowed: 'bad-request',
ea195dc1732d Allow publication of more than 1 item.
Ralph Meijer <ralphm@ik.nu>
parents: 2
diff changeset
27 backend.PayloadExpected: 'bad-request',
ea195dc1732d Allow publication of more than 1 item.
Ralph Meijer <ralphm@ik.nu>
parents: 2
diff changeset
28 }
ea195dc1732d Allow publication of more than 1 item.
Ralph Meijer <ralphm@ik.nu>
parents: 2
diff changeset
29
1
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
30 class ComponentServiceFromBackend(component.Service, utility.EventDispatcher):
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
31
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
32 def __init__(self, backend):
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
33 utility.EventDispatcher.__init__(self)
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
34 self.backend = backend
2
9701df89c534 First take at notifications
Ralph Meijer <ralphm@ik.nu>
parents: 1
diff changeset
35 self.backend.pubsub_service = self
1
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
36 self.addObserver(PUBSUB_PUBLISH, self.onPublish)
16
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
37 self.addObserver(PUBSUB_SUBSCRIBE, self.onSubscribe)
7
a8cfb31dc50c Implemented fallback for feature-not-implemented.
Ralph Meijer <ralphm@ik.nu>
parents: 4
diff changeset
38 self.addObserver(PUBSUB_OPTIONS_GET, self.onOptionsGet)
a8cfb31dc50c Implemented fallback for feature-not-implemented.
Ralph Meijer <ralphm@ik.nu>
parents: 4
diff changeset
39 self.addObserver(PUBSUB_CONFIGURE_GET, self.onConfigureGet)
a8cfb31dc50c Implemented fallback for feature-not-implemented.
Ralph Meijer <ralphm@ik.nu>
parents: 4
diff changeset
40 self.addObserver(PUBSUB_GET, self.notImplemented, -1)
a8cfb31dc50c Implemented fallback for feature-not-implemented.
Ralph Meijer <ralphm@ik.nu>
parents: 4
diff changeset
41 self.addObserver(PUBSUB_SET, self.notImplemented, -1)
1
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
42
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
43 def componentConnected(self, xmlstream):
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
44 xmlstream.addObserver(PUBSUB_SET, self.onPubSub)
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
45 xmlstream.addObserver(PUBSUB_GET, self.onPubSub)
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
46
9
52bd563b7a5d Add disco support.
Ralph Meijer <ralphm@ik.nu>
parents: 7
diff changeset
47 def getIdentities(self, node):
52bd563b7a5d Add disco support.
Ralph Meijer <ralphm@ik.nu>
parents: 7
diff changeset
48 results = []
52bd563b7a5d Add disco support.
Ralph Meijer <ralphm@ik.nu>
parents: 7
diff changeset
49 if not node:
52bd563b7a5d Add disco support.
Ralph Meijer <ralphm@ik.nu>
parents: 7
diff changeset
50 results.append({
52bd563b7a5d Add disco support.
Ralph Meijer <ralphm@ik.nu>
parents: 7
diff changeset
51 'category': 'pubsub',
52bd563b7a5d Add disco support.
Ralph Meijer <ralphm@ik.nu>
parents: 7
diff changeset
52 'type': 'generic',
52bd563b7a5d Add disco support.
Ralph Meijer <ralphm@ik.nu>
parents: 7
diff changeset
53 'name': 'Generic Pubsub Service'
52bd563b7a5d Add disco support.
Ralph Meijer <ralphm@ik.nu>
parents: 7
diff changeset
54 })
52bd563b7a5d Add disco support.
Ralph Meijer <ralphm@ik.nu>
parents: 7
diff changeset
55 return results
52bd563b7a5d Add disco support.
Ralph Meijer <ralphm@ik.nu>
parents: 7
diff changeset
56
12
d45e921a5d2a Return implemented features
Ralph Meijer <ralphm@ik.nu>
parents: 9
diff changeset
57 def getFeatures(self, node):
d45e921a5d2a Return implemented features
Ralph Meijer <ralphm@ik.nu>
parents: 9
diff changeset
58 return [
d45e921a5d2a Return implemented features
Ralph Meijer <ralphm@ik.nu>
parents: 9
diff changeset
59 "http://jabber.org/protocol/pubsub#outcast-affil",
d45e921a5d2a Return implemented features
Ralph Meijer <ralphm@ik.nu>
parents: 9
diff changeset
60 "http://jabber.org/protocol/pubsub#publisher-affil",
16
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
61 "http://jabber.org/protocol/pubsub#persistent-items",
12
d45e921a5d2a Return implemented features
Ralph Meijer <ralphm@ik.nu>
parents: 9
diff changeset
62 ]
d45e921a5d2a Return implemented features
Ralph Meijer <ralphm@ik.nu>
parents: 9
diff changeset
63
1
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
64 def error(self, failure, iq):
16
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
65 try:
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
66 r = failure.trap(*error_map.keys())
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
67 xmpp_error.error_from_iq(iq, error_map[r], failure.value.msg)
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
68 return iq
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
69 except:
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
70 xmpp_error.error_from_iq(iq, 'internal-server-error')
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
71 self.send(iq)
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
72 raise
1
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
73
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
74 def success(self, result, iq):
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
75 iq.swapAttributeValues("to", "from")
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
76 iq["type"] = 'result'
18
7937d6fbbe2a Small code cleanups
Ralph Meijer <ralphm@ik.nu>
parents: 16
diff changeset
77 iq.children = result or []
1
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
78 return iq
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
79
7
a8cfb31dc50c Implemented fallback for feature-not-implemented.
Ralph Meijer <ralphm@ik.nu>
parents: 4
diff changeset
80 def notImplemented(self, iq):
a8cfb31dc50c Implemented fallback for feature-not-implemented.
Ralph Meijer <ralphm@ik.nu>
parents: 4
diff changeset
81 self.send(xmpp_error.error_from_iq(iq, 'feature-not-implemented'))
a8cfb31dc50c Implemented fallback for feature-not-implemented.
Ralph Meijer <ralphm@ik.nu>
parents: 4
diff changeset
82
1
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
83 def onPubSub(self, iq):
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
84 self.dispatch(iq)
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
85 iq.handled = True
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
86
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
87 def onPublish(self, iq):
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
88 node = iq.pubsub.publish["node"]
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
89
4
ea195dc1732d Allow publication of more than 1 item.
Ralph Meijer <ralphm@ik.nu>
parents: 2
diff changeset
90 items = []
ea195dc1732d Allow publication of more than 1 item.
Ralph Meijer <ralphm@ik.nu>
parents: 2
diff changeset
91 for child in iq.pubsub.publish.children:
ea195dc1732d Allow publication of more than 1 item.
Ralph Meijer <ralphm@ik.nu>
parents: 2
diff changeset
92 if child.__class__ == domish.Element and child.name == 'item':
ea195dc1732d Allow publication of more than 1 item.
Ralph Meijer <ralphm@ik.nu>
parents: 2
diff changeset
93 items.append(child)
ea195dc1732d Allow publication of more than 1 item.
Ralph Meijer <ralphm@ik.nu>
parents: 2
diff changeset
94
ea195dc1732d Allow publication of more than 1 item.
Ralph Meijer <ralphm@ik.nu>
parents: 2
diff changeset
95 print items
ea195dc1732d Allow publication of more than 1 item.
Ralph Meijer <ralphm@ik.nu>
parents: 2
diff changeset
96
ea195dc1732d Allow publication of more than 1 item.
Ralph Meijer <ralphm@ik.nu>
parents: 2
diff changeset
97 d = self.backend.do_publish(node, jid.JID(iq["from"]).userhost(), items)
1
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
98 d.addCallback(self.success, iq)
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
99 d.addErrback(self.error, iq)
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
100 d.addCallback(self.send)
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
101
7
a8cfb31dc50c Implemented fallback for feature-not-implemented.
Ralph Meijer <ralphm@ik.nu>
parents: 4
diff changeset
102 def onOptionsGet(self, iq):
16
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
103 xmpp_error.error_from_iq(iq, 'feature-not-implemented')
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
104 iq.error.addElement((NS_PUBSUB_ERRORS, 'subscription-options-unavailable'), NS_PUBSUB_ERRORS)
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
105 self.send(iq)
7
a8cfb31dc50c Implemented fallback for feature-not-implemented.
Ralph Meijer <ralphm@ik.nu>
parents: 4
diff changeset
106
a8cfb31dc50c Implemented fallback for feature-not-implemented.
Ralph Meijer <ralphm@ik.nu>
parents: 4
diff changeset
107 def onConfigureGet(self, iq):
16
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
108 xmpp_error.error_from_iq(iq, 'feature-not-implemented')
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
109 iq.error.addElement((NS_PUBSUB_ERRORS, 'node-not-configurable'), NS_PUBSUB_ERRORS)
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
110 self.send(iq)
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
111
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
112 def onSubscribe(self, iq):
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
113 node_id = iq.pubsub.subscribe["node"]
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
114 subscriber = jid.JID(iq.pubsub.subscribe["jid"])
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
115 requestor = jid.JID(iq["from"]).userhostJID()
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
116 d = self.backend.do_subscribe(node_id, subscriber, requestor)
18
7937d6fbbe2a Small code cleanups
Ralph Meijer <ralphm@ik.nu>
parents: 16
diff changeset
117 d.addCallback(self.return_subscription)
7937d6fbbe2a Small code cleanups
Ralph Meijer <ralphm@ik.nu>
parents: 16
diff changeset
118 d.addCallback(self.succeed, iq)
16
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
119 d.addErrback(self.error, iq)
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
120 d.addCallback(self.send)
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
121
18
7937d6fbbe2a Small code cleanups
Ralph Meijer <ralphm@ik.nu>
parents: 16
diff changeset
122 def return_subscription(self, result):
7937d6fbbe2a Small code cleanups
Ralph Meijer <ralphm@ik.nu>
parents: 16
diff changeset
123 reply = domish.Element("pubsub", NS_PUBSUB)
16
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
124 entity = reply.addElement("entity")
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
125 entity["node"] = result["node"]
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
126 entity["jid"] = result["jid"].full()
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
127 entity["affiliation"] = result["affiliation"]
ce3d0db64da1 Implemented basic subscribing.
Ralph Meijer <ralphm@ik.nu>
parents: 12
diff changeset
128 entity["subscription"] = result["subscription"]
18
7937d6fbbe2a Small code cleanups
Ralph Meijer <ralphm@ik.nu>
parents: 16
diff changeset
129 return reply
7
a8cfb31dc50c Implemented fallback for feature-not-implemented.
Ralph Meijer <ralphm@ik.nu>
parents: 4
diff changeset
130
4
ea195dc1732d Allow publication of more than 1 item.
Ralph Meijer <ralphm@ik.nu>
parents: 2
diff changeset
131 def do_notification(self, list, node):
1
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
132
4
ea195dc1732d Allow publication of more than 1 item.
Ralph Meijer <ralphm@ik.nu>
parents: 2
diff changeset
133 for recipient, items in list.items():
ea195dc1732d Allow publication of more than 1 item.
Ralph Meijer <ralphm@ik.nu>
parents: 2
diff changeset
134 self.notify(node, items, recipient)
2
9701df89c534 First take at notifications
Ralph Meijer <ralphm@ik.nu>
parents: 1
diff changeset
135
4
ea195dc1732d Allow publication of more than 1 item.
Ralph Meijer <ralphm@ik.nu>
parents: 2
diff changeset
136 def notify(self, node, itemlist, recipient):
2
9701df89c534 First take at notifications
Ralph Meijer <ralphm@ik.nu>
parents: 1
diff changeset
137 message = domish.Element((NS_COMPONENT, "message"))
9701df89c534 First take at notifications
Ralph Meijer <ralphm@ik.nu>
parents: 1
diff changeset
138 message["from"] = self.parent.jabberId
9701df89c534 First take at notifications
Ralph Meijer <ralphm@ik.nu>
parents: 1
diff changeset
139 message["to"] = recipient
9701df89c534 First take at notifications
Ralph Meijer <ralphm@ik.nu>
parents: 1
diff changeset
140 x = message.addElement((NS_PUBSUB_EVENT, "x"), NS_PUBSUB_EVENT)
9701df89c534 First take at notifications
Ralph Meijer <ralphm@ik.nu>
parents: 1
diff changeset
141 items = x.addElement("items")
9701df89c534 First take at notifications
Ralph Meijer <ralphm@ik.nu>
parents: 1
diff changeset
142 items["node"] = node
4
ea195dc1732d Allow publication of more than 1 item.
Ralph Meijer <ralphm@ik.nu>
parents: 2
diff changeset
143 items.children.extend(itemlist)
2
9701df89c534 First take at notifications
Ralph Meijer <ralphm@ik.nu>
parents: 1
diff changeset
144 self.send(message)
9701df89c534 First take at notifications
Ralph Meijer <ralphm@ik.nu>
parents: 1
diff changeset
145
1
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
146 """
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
147 def onCreateSet(self, iq):
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
148 node = iq.pubsub.create["node"]
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
149 owner = jid.JID(iq["from"]).userhost()
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
150
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
151 try:
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
152 node = self.backend.create_node(node, owner)
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
153
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
154 if iq.pubsub.create["node"] == None:
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
155 # also show node name
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
156 except:
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
157 pass
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
158
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
159 iq.handled = True
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
160 """
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
161
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
162 components.registerAdapter(ComponentServiceFromBackend, backend.IBackendService, component.IService)
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
163