comparison idavoll/backend.py @ 171:bc269696ef42

Reply with the correct error condition on subscription when not subscribed. Author: ralphm. Fixes #7.
author Ralph Meijer <ralphm@ik.nu>
date Thu, 03 Jan 2008 13:10:25 +0000
parents 96afb248df5e
children 9bfb00edd0cc
comparison
equal deleted inserted replaced
170:958e69630e52 171:bc269696ef42
1 # -*- test-case-name: idavoll.test.test_backend -*- 1 # -*- test-case-name: idavoll.test.test_backend -*-
2 # 2 #
3 # Copyright (c) 2003-2007 Ralph Meijer 3 # Copyright (c) 2003-2008 Ralph Meijer
4 # See LICENSE for details. 4 # See LICENSE for details.
5 5
6 import uuid 6 import uuid
7 7
8 from zope.interface import implements 8 from zope.interface import implements
21 21
22 def _get_affiliation(node, entity): 22 def _get_affiliation(node, entity):
23 d = node.get_affiliation(entity) 23 d = node.get_affiliation(entity)
24 d.addCallback(lambda affiliation: (node, affiliation)) 24 d.addCallback(lambda affiliation: (node, affiliation))
25 return d 25 return d
26
26 27
27 class BackendService(service.Service, utility.EventDispatcher): 28 class BackendService(service.Service, utility.EventDispatcher):
28 29
29 implements(iidavoll.IBackendService) 30 implements(iidavoll.IBackendService)
30 31
358 implements(IDisco) 359 implements(IDisco)
359 360
360 _errorMap = { 361 _errorMap = {
361 error.NodeNotFound: ('item-not-found', None, None), 362 error.NodeNotFound: ('item-not-found', None, None),
362 error.NodeExists: ('conflict', None, None), 363 error.NodeExists: ('conflict', None, None),
363 error.SubscriptionNotFound: ('not-authorized',
364 'not-subscribed',
365 None),
366 error.Forbidden: ('forbidden', None, None), 364 error.Forbidden: ('forbidden', None, None),
367 error.ItemForbidden: ('bad-request', 'item-forbidden', None), 365 error.ItemForbidden: ('bad-request', 'item-forbidden', None),
368 error.ItemRequired: ('bad-request', 'item-required', None), 366 error.ItemRequired: ('bad-request', 'item-required', None),
369 error.NoInstantNodes: ('not-acceptable', 367 error.NoInstantNodes: ('not-acceptable',
370 'unsupported', 368 'unsupported',
371 'instant-nodes'), 369 'instant-nodes'),
372 error.NotSubscribed: ('not-authorized', 'not-subscribed', None), 370 error.NotSubscribed: ('unexpected-request', 'not-subscribed', None),
373 error.InvalidConfigurationOption: ('not-acceptable', None, None), 371 error.InvalidConfigurationOption: ('not-acceptable', None, None),
374 error.InvalidConfigurationValue: ('not-acceptable', None, None), 372 error.InvalidConfigurationValue: ('not-acceptable', None, None),
375 error.NodeNotPersistent: ('feature-not-implemented', 373 error.NodeNotPersistent: ('feature-not-implemented',
376 'unsupported', 374 'unsupported',
377 'persistent-node'), 375 'persistent-node'),