comparison idavoll/backend.py @ 53:e602ddda2d6e

Implement NodeCreationService, using the create_node() method of Storage. Replace get_supported_affiliations() by supports_publisher_affiliation() and supports_outcast_affiliation() in BackendService. Add supports_persistent_items() in BackendService.
author Ralph Meijer <ralphm@ik.nu>
date Fri, 05 Nov 2004 17:03:59 +0000
parents 94e4ede2a357
children 0fa161c00ed9
comparison
equal deleted inserted replaced
52:0947b46c0968 53:e602ddda2d6e
139 def __init__(self, storage): 139 def __init__(self, storage):
140 service.MultiService.__init__(self) 140 service.MultiService.__init__(self)
141 utility.EventDispatcher.__init__(self) 141 utility.EventDispatcher.__init__(self)
142 self.storage = storage 142 self.storage = storage
143 143
144 def get_supported_affiliations(self): 144 def supports_publisher_affiliation(self):
145 return ['none', 'owner', 'outcast', 'publisher'] 145 return True
146
147 def supports_outcast_affiliation(self):
148 return True
149
150 def supports_persistent_items(self):
151 return True
146 152
147 class PublishService(service.Service): 153 class PublishService(service.Service):
148 154
149 __implements__ = IPublishService, 155 __implements__ = IPublishService,
150 156
254 return d 260 return d
255 261
256 def _do_unsubscribe(self, result, node_id, subscriber): 262 def _do_unsubscribe(self, result, node_id, subscriber):
257 return self.parent.storage.remove_subscription(node_id, 263 return self.parent.storage.remove_subscription(node_id,
258 subscriber.full()) 264 subscriber.full())
265
266 class NodeCreationService(service.Service):
267
268 __implements__ = INodeCreationService,
269
270 def supports_instant_nodes(self):
271 return False
272
273 def create_node(self, node_id, requestor):
274 if not node_id:
275 raise NoInstantNodes
276
277 d = self.parent.storage.create_node(node_id, requestor.full())
278 d.addCallback(lambda _: node_id)
279 return d