comparison idavoll/memory_storage.py @ 173:246911bcb699

Make node type part of node configuration.
author Ralph Meijer <ralphm@ik.nu>
date Wed, 09 Apr 2008 11:43:16 +0000
parents bc269696ef42
children 42e23a62b57f
comparison
equal deleted inserted replaced
172:9bfb00edd0cc 173:246911bcb699
7 from twisted.words.protocols.jabber import jid 7 from twisted.words.protocols.jabber import jid
8 8
9 from idavoll import error, iidavoll 9 from idavoll import error, iidavoll
10 10
11 default_config = {"pubsub#persist_items": True, 11 default_config = {"pubsub#persist_items": True,
12 "pubsub#deliver_payloads": True} 12 "pubsub#deliver_payloads": True,
13 "pubsub#node_type": "leaf"}
13 14
14 class Storage: 15 class Storage:
15 16
16 implements(iidavoll.IStorage) 17 implements(iidavoll.IStorage)
17 18
27 return defer.succeed(node) 28 return defer.succeed(node)
28 29
29 def get_node_ids(self): 30 def get_node_ids(self):
30 return defer.succeed(self._nodes.keys()) 31 return defer.succeed(self._nodes.keys())
31 32
32 def create_node(self, node_id, owner, config = None, type='leaf'): 33 def create_node(self, node_id, owner, config=None):
33 if node_id in self._nodes: 34 if node_id in self._nodes:
34 return defer.fail(error.NodeExists()) 35 return defer.fail(error.NodeExists())
35 36
36 if not config: 37 if not config:
37 config = copy.copy(default_config) 38 config = copy.copy(default_config)
38 39
39 if type != 'leaf': 40 if config['pubsub#node_type'] != 'leaf':
40 raise NotImplementedError 41 raise NotImplementedError
41 42
42 node = LeafNode(node_id, owner, config) 43 node = LeafNode(node_id, owner, config)
43 self._nodes[node_id] = node 44 self._nodes[node_id] = node
44 45