]> granicus.if.org Git - python/commitdiff
[Patch #893642] Add optional allow_none argument to SimpleXMLRPCServer, CGIXMLRPCRequ...
authorAndrew M. Kuchling <amk@amk.ca>
Sun, 4 Dec 2005 16:34:40 +0000 (16:34 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Sun, 4 Dec 2005 16:34:40 +0000 (16:34 +0000)
Doc/lib/libsimplexmlrpc.tex
Lib/SimpleXMLRPCServer.py
Misc/NEWS

index 00a46942b4b3f51ce8d7c9a675d95e226f37678b..4d179f6c4e24bcef18922f1f087c81361d8dd260 100644 (file)
@@ -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}{}
index f9999f6d8c78429e020b65c095adb3eee316c0b0..d584971822dbb4d23a50e0929f8cdcd4fdfb10b6 100644 (file)
@@ -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"""
index bf682a22646bf1ade3612acf0754324985ccbfbe..bc8382ec212fce8eff03566cbb7ba3060410f820 100644 (file)
--- 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.