mirror of
https://github.com/python/cpython.git
synced 2025-08-27 04:05:34 +00:00
bpo-7769: enable xmlrpc.server.SimpleXMLRPCDispatcher.register_function used as decorator (GH-231)
This commit is contained in:
parent
7c8b3fa31c
commit
267b9d2fa8
5 changed files with 80 additions and 20 deletions
|
@ -106,6 +106,7 @@ server.handle_request()
|
|||
|
||||
from xmlrpc.client import Fault, dumps, loads, gzip_encode, gzip_decode
|
||||
from http.server import BaseHTTPRequestHandler
|
||||
from functools import partial
|
||||
import http.server
|
||||
import socketserver
|
||||
import sys
|
||||
|
@ -204,17 +205,22 @@ class SimpleXMLRPCDispatcher:
|
|||
self.instance = instance
|
||||
self.allow_dotted_names = allow_dotted_names
|
||||
|
||||
def register_function(self, function, name=None):
|
||||
def register_function(self, function=None, name=None):
|
||||
"""Registers a function to respond to XML-RPC requests.
|
||||
|
||||
The optional name argument can be used to set a Unicode name
|
||||
for the function.
|
||||
"""
|
||||
# decorator factory
|
||||
if function is None:
|
||||
return partial(self.register_function, name=name)
|
||||
|
||||
if name is None:
|
||||
name = function.__name__
|
||||
self.funcs[name] = function
|
||||
|
||||
return function
|
||||
|
||||
def register_introspection_functions(self):
|
||||
"""Registers the XML-RPC introspection methods in the system
|
||||
namespace.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue