comparison idavoll/memory_backend.py @ 74:0e642e5b4fb2

Add get_affiliations(), get_subscriptions(), get_node_type() and get_nodes() to Storage. Add AffiliationsService as subclass of backend.AffiliationsService.
author Ralph Meijer <ralphm@ik.nu>
date Sun, 07 Nov 2004 14:46:35 +0000
parents 0fa161c00ed9
children bbebadd71d35
comparison
equal deleted inserted replaced
73:5d7a924ebddb 74:0e642e5b4fb2
104 node.affiliations[owner.full()] = 'owner' 104 node.affiliations[owner.full()] = 'owner'
105 self.nodes[node_id] = node 105 self.nodes[node_id] = node
106 106
107 return defer.succeed(None) 107 return defer.succeed(None)
108 108
109 def get_affiliations(self, entity):
110 affiliations = []
111 for node in self.nodes.itervalues():
112 if entity.full() in node.affiliations:
113 affiliations.append((node.id,
114 node.affiliations[entity.full()]))
115
116 return defer.succeed(affiliations)
117
118 def get_subscriptions(self, entity):
119 subscriptions = []
120 for node in self.nodes.itervalues():
121 for subscriber, subscription in node.subscriptions.iteritems():
122 subscriber_jid = jid.JID(subscriber)
123 if subscriber_jid.userhostJID() == entity:
124 subscriptions.append((node.id, subscriber_jid,
125 subscription.state))
126 return defer.succeed(subscriptions)
127
128 def get_node_type(self, node_id):
129 if node_id not in self.nodes:
130 raise backend.NodeNotFound
131
132 return defer.succeed('leaf')
133
134 def get_nodes(self):
135 return defer.succeed(self.nodes.keys())
136
109 class BackendService(backend.BackendService): 137 class BackendService(backend.BackendService):
110 pass 138 pass
111 139
112 class NodeCreationService(backend.NodeCreationService): 140 class NodeCreationService(backend.NodeCreationService):
113 pass 141 pass
118 class NotificationService(backend.NotificationService): 146 class NotificationService(backend.NotificationService):
119 pass 147 pass
120 148
121 class SubscriptionService(backend.SubscriptionService): 149 class SubscriptionService(backend.SubscriptionService):
122 pass 150 pass
151
152 class AffiliationsService(backend.AffiliationsService):
153 pass