(self, *args, **kwargs)
| 261 | return has_args, has_id and has_args |
| 262 | |
| 263 | def dispatch_request(self, *args, **kwargs): |
| 264 | http_method = flask.request.method.lower() |
| 265 | if http_method == 'head': |
| 266 | http_method = 'get' |
| 267 | |
| 268 | assert self.cmd in self.operations, \ |
| 269 | 'Unimplemented command ({0}) for {1}'.format( |
| 270 | self.cmd, |
| 271 | str(self.__class__.__name__) |
| 272 | ) |
| 273 | |
| 274 | has_args, has_id = self.check_args(**kwargs) |
| 275 | |
| 276 | assert ( |
| 277 | self.cmd in self.operations and |
| 278 | (has_id and len(self.operations[self.cmd]) > 0 and |
| 279 | http_method in self.operations[self.cmd][0]) or |
| 280 | (not has_id and len(self.operations[self.cmd]) > 1 and |
| 281 | http_method in self.operations[self.cmd][1]) or |
| 282 | (len(self.operations[self.cmd]) > 2 and |
| 283 | http_method in self.operations[self.cmd][2]) |
| 284 | ), \ |
| 285 | 'Unimplemented method ({0}) for command ({1}), which {2} ' \ |
| 286 | 'an id'.format(http_method, |
| 287 | self.cmd, |
| 288 | 'requires' if has_id else 'does not require') |
| 289 | meth = None |
| 290 | if has_id: |
| 291 | meth = self.operations[self.cmd][0][http_method] |
| 292 | elif has_args and http_method in self.operations[self.cmd][1]: |
| 293 | meth = self.operations[self.cmd][1][http_method] |
| 294 | else: |
| 295 | meth = self.operations[self.cmd][2][http_method] |
| 296 | |
| 297 | method = getattr(self, meth, None) |
| 298 | |
| 299 | if method is None: |
| 300 | return make_json_response( |
| 301 | status=406, |
| 302 | success=0, |
| 303 | errormsg=gettext( |
| 304 | 'Unimplemented method ({0}) for this url ({1})').format( |
| 305 | meth, flask.request.path |
| 306 | ) |
| 307 | ) |
| 308 | |
| 309 | return method(*args, **kwargs) |
| 310 | |
| 311 | @classmethod |
| 312 | def register_node_view(cls, blueprint): |
nothing calls this directly
no test coverage detected