comparison idavoll/memory_backend.py @ 54:62fdb37234e5

Make NodeCreationService a subclass of backend.NodeCreationService. Implement create_node() in Storage.
author Ralph Meijer <ralphm@ik.nu>
date Fri, 05 Nov 2004 17:05:36 +0000
parents 64f0986d8b35
children 0fa161c00ed9
comparison
equal deleted inserted replaced
53:e602ddda2d6e 54:62fdb37234e5
94 except KeyError: 94 except KeyError:
95 raise backend.NotSubscribed 95 raise backend.NotSubscribed
96 96
97 return defer.succeed(None) 97 return defer.succeed(None)
98 98
99 def create_node(self, node_id, owner):
100 if node_id in self.nodes:
101 raise backend.NodeExists
102
103 node = Node(node_id)
104 node.affiliations[owner] = 'owner'
105 self.nodes[node_id] = node
106
107 return defer.succeed(None)
108
99 class BackendService(backend.BackendService): 109 class BackendService(backend.BackendService):
100 pass 110 pass
101 111
102 class NodeCreationService(service.Service): 112 class NodeCreationService(backend.NodeCreationService):
103 113 pass
104 __implements__ = backend.INodeCreationService,
105
106 def create_node(self, node_id, requestor):
107 if not node_id:
108 raise backend.NoInstantNodes
109
110 if node_id in self.parent.storage.nodes:
111 raise backend.NodeExists
112
113 node = Node(node_id)
114 node.affiliations[requestor.full()] = 'owner'
115 self.parent.storage.nodes[node_id] = node
116
117 return defer.succeed({'node_id': node.id})
118 114
119 class PublishService(backend.PublishService): 115 class PublishService(backend.PublishService):
120 pass 116 pass
121 117
122 class NotificationService(backend.NotificationService): 118 class NotificationService(backend.NotificationService):