summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2004-08-22 16:04:50 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2004-08-22 16:04:50 (GMT)
commit12237b3a19336636ae40f687fab2e3fdd7c35b4b (patch)
tree164af4ff08c024d8d96c8cb1c05c03ea7ca7571d /Lib
parentd3b0babf6628d0c97f08212357de89be471a758f (diff)
downloadcpython-12237b3a19336636ae40f687fab2e3fdd7c35b4b.zip
cpython-12237b3a19336636ae40f687fab2e3fdd7c35b4b.tar.gz
cpython-12237b3a19336636ae40f687fab2e3fdd7c35b4b.tar.bz2
Replace yield with sequence class. Fixes #1009803.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/xmlrpclib.py29
1 files changed, 21 insertions, 8 deletions
diff --git a/Lib/xmlrpclib.py b/Lib/xmlrpclib.py
index 0ad1077..e3895bd 100644
--- a/Lib/xmlrpclib.py
+++ b/Lib/xmlrpclib.py
@@ -892,15 +892,19 @@ class _MultiCallMethod:
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 @@ if __name__ == "__main__":
# 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