[Python-checkins] python/dist/src/Lib xmlrpclib.py,1.34,1.35

loewis at users.sourceforge.net loewis at users.sourceforge.net
Sun Aug 22 18:04:53 CEST 2004


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5224/Lib

Modified Files:
	xmlrpclib.py 
Log Message:
Replace yield with sequence class. Fixes #1009803.


Index: xmlrpclib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/xmlrpclib.py,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- xmlrpclib.py	20 Aug 2004 07:31:37 -0000	1.34
+++ xmlrpclib.py	22 Aug 2004 16:04:50 -0000	1.35
@@ -892,15 +892,19 @@
     def __call__(self, *args):
         self.__call_list.append((self.__name, args))
 
-def MultiCallIterator(results):
+class MultiCallIterator:
     """Iterates over the results of a multicall. Exceptions are
     thrown in response to xmlrpc faults."""
 
-    for i in results:
-        if type(i) == type({}):
-            raise Fault(i['faultCode'], i['faultString'])
-        elif type(i) == type([]):
-            yield i[0]
+    def __init__(self, results):
+        self.results = results
+
+    def __getitem__(self, i):
+        item = self.results[i]
+        if type(item) == type({}):
+            raise Fault(item['faultCode'], item['faultString'])
+        elif type(item) == type([]):
+            return item[0]
         else:
             raise ValueError,\
                   "unexpected type in multicall result"
@@ -1412,11 +1416,20 @@
     # simple test program (from the XML-RPC specification)
 
     # server = ServerProxy("http://localhost:8000") # local server
-    server = ServerProxy("http://betty.userland.com")
+    server = ServerProxy("http://time.xmlrpc.com/RPC2")
 
     print server
 
     try:
-        print server.examples.getStateName(41)
+        print server.currentTime.getCurrentTime()
+    except Error, v:
+        print "ERROR", v
+
+    multi = MultiCall(server)
+    multi.currentTime.getCurrentTime()
+    multi.currentTime.getCurrentTime()
+    try:
+        for response in multi():
+            print response
     except Error, v:
         print "ERROR", v



More information about the Python-checkins mailing list