comparison idavoll/generic_backend.py @ 162:84cfe9fe38c5

Comply with the access model 'open'. Currently, the only implemented access model is 'open', so we should not check for the subscription of the requestor for item retrieval. We do reject outcasts.
author Ralph Meijer <ralphm@ik.nu>
date Wed, 06 Sep 2006 12:57:53 +0000
parents 6fe78048baf9
children
comparison
equal deleted inserted replaced
161:d0dfc01f7638 162:84cfe9fe38c5
263 263
264 implements(backend.IItemRetrievalService) 264 implements(backend.IItemRetrievalService)
265 265
266 def get_items(self, node_id, requestor, max_items=None, item_ids=[]): 266 def get_items(self, node_id, requestor, max_items=None, item_ids=[]):
267 d = self.parent.storage.get_node(node_id) 267 d = self.parent.storage.get_node(node_id)
268 d.addCallback(self._is_subscribed, requestor) 268 d.addCallback(_get_affiliation, requestor)
269 d.addCallback(self._do_get_items, max_items, item_ids) 269 d.addCallback(self._do_get_items, max_items, item_ids)
270 return d 270 return d
271 271
272 def _is_subscribed(self, node, subscriber):
273 d = node.is_subscribed(subscriber)
274 d.addCallback(lambda subscribed: (node, subscribed))
275 return d
276
277 def _do_get_items(self, result, max_items, item_ids): 272 def _do_get_items(self, result, max_items, item_ids):
278 node, subscribed = result 273 node, affiliation = result
279 274
280 if not subscribed: 275 if affiliation == 'outcast':
281 raise backend.NotSubscribed 276 raise backend.Forbidden
282 277
283 if item_ids: 278 if item_ids:
284 return node.get_items_by_id(item_ids) 279 return node.get_items_by_id(item_ids)
285 else: 280 else:
286 return node.get_items(max_items) 281 return node.get_items(max_items)