Skip to content

Commit d032fc8

Browse files
author
andrew.kuchling
committed
[Patch #893642] Add optional allow_none argument to SimpleXMLRPCServer, CGIXMLRPCRequestHandler
git-svn-id: http://svn.python.org/projects/python/trunk@41589 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent fd6eae6 commit d032fc8

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

Doc/lib/libsimplexmlrpc.tex

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ \section{\module{SimpleXMLRPCServer} ---
1313
CGI environment, using \class{CGIXMLRPCRequestHandler}.
1414

1515
\begin{classdesc}{SimpleXMLRPCServer}{addr\optional{,
16-
requestHandler\optional{, logRequests}}}
16+
requestHandler\optional{,
17+
logRequests\optional{allow_none}}}}
1718

1819
Create a new server instance. The \var{requestHandler} parameter
1920
should be a factory for request handler instances; it defaults to
@@ -24,11 +25,13 @@ \section{\module{SimpleXMLRPCServer} ---
2425
setting this parameter to false will turn off logging. This class
2526
provides methods for registration of functions that can be called by
2627
the XML-RPC protocol.
28+
\versionchanged[The \var{allow_none} parameter was added]{2.5}
2729
\end{classdesc}
2830

29-
\begin{classdesc}{CGIXMLRPCRequestHandler}{}
31+
\begin{classdesc}{CGIXMLRPCRequestHandler}{\optional{allow_none}}
3032
Create a new instance to handle XML-RPC requests in a CGI
3133
environment. \versionadded{2.3}
34+
\versionchanged[The \var{allow_none} parameter was added]{2.5}
3235
\end{classdesc}
3336

3437
\begin{classdesc}{SimpleXMLRPCRequestHandler}{}

Lib/SimpleXMLRPCServer.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,10 @@ class SimpleXMLRPCDispatcher:
159159
reason to instantiate this class directly.
160160
"""
161161

162-
def __init__(self):
162+
def __init__(self, allow_none):
163163
self.funcs = {}
164164
self.instance = None
165+
self.allow_none = allow_none
165166

166167
def register_instance(self, instance, allow_dotted_names=False):
167168
"""Registers an instance to respond to XML-RPC requests.
@@ -251,7 +252,8 @@ def _marshaled_dispatch(self, data, dispatch_method = None):
251252
response = self._dispatch(method, params)
252253
# wrap response in a singleton tuple
253254
response = (response,)
254-
response = xmlrpclib.dumps(response, methodresponse=1)
255+
response = xmlrpclib.dumps(response, methodresponse=1,
256+
allow_none = self.allow_none)
255257
except Fault, fault:
256258
response = xmlrpclib.dumps(fault)
257259
except:
@@ -479,10 +481,10 @@ class SimpleXMLRPCServer(SocketServer.TCPServer,
479481
allow_reuse_address = True
480482

481483
def __init__(self, addr, requestHandler=SimpleXMLRPCRequestHandler,
482-
logRequests=1):
484+
logRequests=1, allow_none=False):
483485
self.logRequests = logRequests
484486

485-
SimpleXMLRPCDispatcher.__init__(self)
487+
SimpleXMLRPCDispatcher.__init__(self, allow_none)
486488
SocketServer.TCPServer.__init__(self, addr, requestHandler)
487489

488490
# [Bug #1222790] If possible, set close-on-exec flag; if a
@@ -496,8 +498,8 @@ def __init__(self, addr, requestHandler=SimpleXMLRPCRequestHandler,
496498
class CGIXMLRPCRequestHandler(SimpleXMLRPCDispatcher):
497499
"""Simple handler for XML-RPC data passed through CGI."""
498500

499-
def __init__(self):
500-
SimpleXMLRPCDispatcher.__init__(self)
501+
def __init__(self, allow_none=False):
502+
SimpleXMLRPCDispatcher.__init__(self, allow_none)
501503

502504
def handle_xmlrpc(self, request_text):
503505
"""Handle a single XML-RPC request"""

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,9 @@ Library
454454
- Bug #792570: SimpleXMLRPCServer had problems if the request grew too large.
455455
Fixed by reading the HTTP body in chunks instead of one big socket.read().
456456

457+
- Patch #893642: add allow_none argument to constructors of
458+
SimpleXMLRPCServer and CGIXMLRPCRequestHandler.
459+
457460
- Bug #1110478: Revert os.environ.update to do putenv again.
458461

459462
- Bug #1103844: fix distutils.install.dump_dirs() with negated options.

0 commit comments

Comments
 (0)