MCPcopy Index your code
hub / github.com/python/cpython / _dispatch

Method _dispatch

Lib/xmlrpc/server.py:372–421  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
423class SimpleXMLRPCRequestHandler(BaseHTTPRequestHandler):
424 """Simple XML-RPC request handler class.

Calls 2

resolve_dotted_attributeFunction · 0.85
funcFunction · 0.50