Mercurial > libervia-pubsub
comparison idavoll/backend.py @ 196:00a6dbfbee42
Return deferreds on failure, instead of raising exceptions.
author | Ralph Meijer <ralphm@ik.nu> |
---|---|
date | Tue, 10 Jun 2008 08:28:57 +0000 |
parents | c21b986cff30 |
children | e404775b12df |
comparison
equal
deleted
inserted
replaced
195:e289636ccc4f | 196:00a6dbfbee42 |
---|---|
246 d.addCallback(self._make_config) | 246 d.addCallback(self._make_config) |
247 return d | 247 return d |
248 | 248 |
249 def get_node_configuration(self, node_id): | 249 def get_node_configuration(self, node_id): |
250 if not node_id: | 250 if not node_id: |
251 raise error.NoRootNode() | 251 return defer.fail(error.NoRootNode()) |
252 | 252 |
253 d = self.storage.get_node(node_id) | 253 d = self.storage.get_node(node_id) |
254 d.addCallback(lambda node: node.get_configuration()) | 254 d.addCallback(lambda node: node.get_configuration()) |
255 | 255 |
256 d.addCallback(self._make_config) | 256 d.addCallback(self._make_config) |
267 | 267 |
268 return options | 268 return options |
269 | 269 |
270 def set_node_configuration(self, node_id, options, requestor): | 270 def set_node_configuration(self, node_id, options, requestor): |
271 if not node_id: | 271 if not node_id: |
272 raise error.NoRootNode() | 272 return defer.fail(error.NoRootNode()) |
273 | 273 |
274 for key, value in options.iteritems(): | 274 for key, value in options.iteritems(): |
275 if not self.options.has_key(key): | 275 if not self.options.has_key(key): |
276 raise error.InvalidConfigurationOption() | 276 return defer.fail(error.InvalidConfigurationOption()) |
277 if self.options[key]["type"] == 'boolean': | 277 if self.options[key]["type"] == 'boolean': |
278 try: | 278 try: |
279 options[key] = bool(int(value)) | 279 options[key] = bool(int(value)) |
280 except ValueError: | 280 except ValueError: |
281 raise error.InvalidConfigurationValue() | 281 return defer.fail(error.InvalidConfigurationValue()) |
282 | 282 |
283 d = self.storage.get_node(node_id) | 283 d = self.storage.get_node(node_id) |
284 d.addCallback(_get_affiliation, requestor) | 284 d.addCallback(_get_affiliation, requestor) |
285 d.addCallback(self._do_set_node_configuration, options) | 285 d.addCallback(self._do_set_node_configuration, options) |
286 return d | 286 return d |