Dispatches the XML-RPC method. XML-RPC calls are forwarded to a registered function that matches the called XML-RPC method name. If no such function exists then the call is forwarded to the registered instance, if available. If the registered instance has a
(self, method, params)
| 370 | return results |
| 371 | |
| 372 | def _dispatch(self, method, params): |
| 373 | """Dispatches the XML-RPC method. |
| 374 | |
| 375 | XML-RPC calls are forwarded to a registered function that |
| 376 | matches the called XML-RPC method name. If no such function |
| 377 | exists then the call is forwarded to the registered instance, |
| 378 | if available. |
| 379 | |
| 380 | If the registered instance has a _dispatch method then that |
| 381 | method will be called with the name of the XML-RPC method and |
| 382 | its parameters as a tuple |
| 383 | e.g. instance._dispatch('add',(2,3)) |
| 384 | |
| 385 | If the registered instance does not have a _dispatch method |
| 386 | then the instance will be searched to find a matching method |
| 387 | and, if found, will be called. |
| 388 | |
| 389 | Methods beginning with an '_' are considered private and will |
| 390 | not be called. |
| 391 | """ |
| 392 | |
| 393 | try: |
| 394 | # call the matching registered function |
| 395 | func = self.funcs[method] |
| 396 | except KeyError: |
| 397 | pass |
| 398 | else: |
| 399 | if func is not None: |
| 400 | return func(*params) |
| 401 | raise Exception('method "%s" is not supported' % method) |
| 402 | |
| 403 | if self.instance is not None: |
| 404 | if hasattr(self.instance, '_dispatch'): |
| 405 | # call the `_dispatch` method on the instance |
| 406 | return self.instance._dispatch(method, params) |
| 407 | |
| 408 | # call the instance's method directly |
| 409 | try: |
| 410 | func = resolve_dotted_attribute( |
| 411 | self.instance, |
| 412 | method, |
| 413 | self.allow_dotted_names |
| 414 | ) |
| 415 | except AttributeError: |
| 416 | pass |
| 417 | else: |
| 418 | if func is not None: |
| 419 | return func(*params) |
| 420 | |
| 421 | raise Exception('method "%s" is not supported' % method) |
| 422 | |
| 423 | class SimpleXMLRPCRequestHandler(BaseHTTPRequestHandler): |
| 424 | """Simple XML-RPC request handler class. |