]> granicus.if.org Git - python/commitdiff
Issue #19082: Working SimpleXMLRPCServer and xmlrpclib examples, both in modules...
authorSenthil Kumaran <senthil@uthcode.com>
Mon, 13 Jan 2014 00:04:08 +0000 (16:04 -0800)
committerSenthil Kumaran <senthil@uthcode.com>
Mon, 13 Jan 2014 00:04:08 +0000 (16:04 -0800)
Doc/library/simplexmlrpcserver.rst
Lib/SimpleXMLRPCServer.py
Lib/xmlrpclib.py
Misc/NEWS

index 1dc68179c7696e21bfb47f5cc33617106207faaa..8f805e9307585bd4c1809287ebd2f3514094a1c1 100644 (file)
@@ -197,6 +197,38 @@ server::
    # Print list of available methods
    print s.system.listMethods()
 
+The following :class:`SimpleXMLRPCServer` example is included in the module
+`Lib/SimpleXMLRPCServer.py`::
+
+    server = SimpleXMLRPCServer(("localhost", 8000))
+    server.register_function(pow)
+    server.register_function(lambda x,y: x+y, 'add')
+    server.register_multicall_functions()
+    server.serve_forever()
+
+This demo server can be run from the command line as::
+
+    python -m SimpleXMLRPCServer
+
+Example client code which talks to the above server is included with
+`Lib/xmlrpclib.py`::
+
+    server = ServerProxy("http://localhost:8000")
+    print server
+    multi = MultiCall(server)
+    multi.pow(2, 9)
+    multi.add(5, 1)
+    multi.add(24, 11)
+    try:
+        for response in multi():
+            print response
+    except Error, v:
+        print "ERROR", v
+
+And the client can be invoked directly using the following command::
+
+    python -m xmlrpclib
+
 
 CGIXMLRPCRequestHandler
 -----------------------
index f15cd62f4cfb676502a574857cc80c934bc7ba3c..fcc3d2ea74dfacf04e6c22db898a0a70184c1ec1 100644 (file)
@@ -704,4 +704,5 @@ if __name__ == '__main__':
     server = SimpleXMLRPCServer(("localhost", 8000))
     server.register_function(pow)
     server.register_function(lambda x,y: x+y, 'add')
+    server.register_multicall_functions()
     server.serve_forever()
index b93ea23b929750c43d737de3d9aca8ccc4da5062..1a8b3fb431b11873f4dce878255a78e3a994ca9c 100644 (file)
@@ -1617,21 +1617,14 @@ Server = ServerProxy
 
 if __name__ == "__main__":
 
-    # simple test program (from the XML-RPC specification)
-
-    # server = ServerProxy("http://localhost:8000") # local server
-    server = ServerProxy("http://time.xmlrpc.com/RPC2")
+    server = ServerProxy("http://localhost:8000")
 
     print server
 
-    try:
-        print server.currentTime.getCurrentTime()
-    except Error, v:
-        print "ERROR", v
-
     multi = MultiCall(server)
-    multi.currentTime.getCurrentTime()
-    multi.currentTime.getCurrentTime()
+    multi.pow(2, 9)
+    multi.add(5, 1)
+    multi.add(24, 11)
     try:
         for response in multi():
             print response
index ddcf535fd874912bb67ad22d6030cd2efa215bb9..6eee65c9a324c4f4fc570cdfb42d545e0c286a8a 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -35,6 +35,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #19082: Working SimpleXMLRPCServer and xmlrpclib examples, both in
+  modules and documentation.
+
 - Issue #13107: argparse and optparse no longer raises an exception when output
   a help on environment with too small COLUMNS.  Based on patch by
   Elazar Gershuni.