changeset 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 5d7a924ebddb
children 1f7b8b6b8ce9
files idavoll/memory_backend.py
diffstat 1 files changed, 31 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/idavoll/memory_backend.py	Sun Nov 07 14:21:09 2004 +0000
+++ b/idavoll/memory_backend.py	Sun Nov 07 14:46:35 2004 +0000
@@ -106,6 +106,34 @@
 
         return defer.succeed(None)
 
+    def get_affiliations(self, entity):
+        affiliations = []
+        for node in self.nodes.itervalues():
+            if entity.full() in node.affiliations:
+                affiliations.append((node.id,
+                                     node.affiliations[entity.full()]))
+
+        return defer.succeed(affiliations)
+
+    def get_subscriptions(self, entity):
+        subscriptions = []
+        for node in self.nodes.itervalues():
+            for subscriber, subscription in node.subscriptions.iteritems():
+                subscriber_jid = jid.JID(subscriber)
+                if subscriber_jid.userhostJID() == entity:
+                    subscriptions.append((node.id, subscriber_jid,
+                                          subscription.state))
+        return defer.succeed(subscriptions)
+
+    def get_node_type(self, node_id):
+        if node_id not in self.nodes:
+            raise backend.NodeNotFound
+
+        return defer.succeed('leaf')
+
+    def get_nodes(self):
+        return defer.succeed(self.nodes.keys())
+
 class BackendService(backend.BackendService):
     pass
 
@@ -120,3 +148,6 @@
 
 class SubscriptionService(backend.SubscriptionService):
     pass
+
+class AffiliationsService(backend.AffiliationsService):
+    pass