From 10a16dea7422a578a2d49a778c5aceb54d2126d2 Mon Sep 17 00:00:00 2001
From: "Andrew M. Kuchling" <amk@amk.ca>
Date: Sun, 4 Dec 2005 16:34:40 +0000
Subject: [Patch #893642] Add optional allow_none argument to
 SimpleXMLRPCServer, CGIXMLRPCRequestHandler

---
 Doc/lib/libsimplexmlrpc.tex |  7 +++++--
 Lib/SimpleXMLRPCServer.py   | 14 ++++++++------
 Misc/NEWS                   |  3 +++
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/Doc/lib/libsimplexmlrpc.tex b/Doc/lib/libsimplexmlrpc.tex
index 00a4694..4d179f6 100644
--- a/Doc/lib/libsimplexmlrpc.tex
+++ b/Doc/lib/libsimplexmlrpc.tex
@@ -13,7 +13,8 @@ be free standing, using \class{SimpleXMLRPCServer}, or embedded in a
 CGI environment, using \class{CGIXMLRPCRequestHandler}.
 
 \begin{classdesc}{SimpleXMLRPCServer}{addr\optional{,
-                                      requestHandler\optional{, logRequests}}}
+                                      requestHandler\optional{,
+					logRequests\optional{allow_none}}}}
 
   Create a new server instance.  The \var{requestHandler} parameter
   should be a factory for request handler instances; it defaults to
@@ -24,11 +25,13 @@ CGI environment, using \class{CGIXMLRPCRequestHandler}.
   setting this parameter to false will turn off logging.  This class
   provides methods for registration of functions that can be called by
   the XML-RPC protocol.
+  \versionchanged[The \var{allow_none} parameter was added]{2.5}
 \end{classdesc}
 
-\begin{classdesc}{CGIXMLRPCRequestHandler}{}
+\begin{classdesc}{CGIXMLRPCRequestHandler}{\optional{allow_none}}
   Create a new instance to handle XML-RPC requests in a CGI
   environment. \versionadded{2.3}
+  \versionchanged[The \var{allow_none} parameter was added]{2.5}
 \end{classdesc}
 
 \begin{classdesc}{SimpleXMLRPCRequestHandler}{}
diff --git a/Lib/SimpleXMLRPCServer.py b/Lib/SimpleXMLRPCServer.py
index f9999f6..d584971 100644
--- a/Lib/SimpleXMLRPCServer.py
+++ b/Lib/SimpleXMLRPCServer.py
@@ -159,9 +159,10 @@ class SimpleXMLRPCDispatcher:
     reason to instantiate this class directly.
     """
 
-    def __init__(self):
+    def __init__(self, allow_none):
         self.funcs = {}
         self.instance = None
+        self.allow_none = allow_none
 
     def register_instance(self, instance, allow_dotted_names=False):
         """Registers an instance to respond to XML-RPC requests.
@@ -251,7 +252,8 @@ class SimpleXMLRPCDispatcher:
                 response = self._dispatch(method, params)
             # wrap response in a singleton tuple
             response = (response,)
-            response = xmlrpclib.dumps(response, methodresponse=1)
+            response = xmlrpclib.dumps(response, methodresponse=1, 
+                                       allow_none = self.allow_none)
         except Fault, fault:
             response = xmlrpclib.dumps(fault)
         except:
@@ -479,10 +481,10 @@ class SimpleXMLRPCServer(SocketServer.TCPServer,
     allow_reuse_address = True
 
     def __init__(self, addr, requestHandler=SimpleXMLRPCRequestHandler,
-                 logRequests=1):
+                 logRequests=1, allow_none=False):
         self.logRequests = logRequests
 
-        SimpleXMLRPCDispatcher.__init__(self)
+        SimpleXMLRPCDispatcher.__init__(self, allow_none)
         SocketServer.TCPServer.__init__(self, addr, requestHandler)
 
         # [Bug #1222790] If possible, set close-on-exec flag; if a 
@@ -496,8 +498,8 @@ class SimpleXMLRPCServer(SocketServer.TCPServer,
 class CGIXMLRPCRequestHandler(SimpleXMLRPCDispatcher):
     """Simple handler for XML-RPC data passed through CGI."""
 
-    def __init__(self):
-        SimpleXMLRPCDispatcher.__init__(self)
+    def __init__(self, allow_none=False):
+        SimpleXMLRPCDispatcher.__init__(self, allow_none)
 
     def handle_xmlrpc(self, request_text):
         """Handle a single XML-RPC request"""
diff --git a/Misc/NEWS b/Misc/NEWS
index bf682a2..bc8382e 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -454,6 +454,9 @@ Library
 - Bug #792570: SimpleXMLRPCServer had problems if the request grew too large.
   Fixed by reading the HTTP body in chunks instead of one big socket.read().
 
+- Patch #893642: add allow_none argument to constructors of 
+  SimpleXMLRPCServer and CGIXMLRPCRequestHandler.
+
 - Bug #1110478: Revert os.environ.update to do putenv again.
 
 - Bug #1103844: fix distutils.install.dump_dirs() with negated options.
-- 
cgit v0.12

