import xmlrpclib class MyServerProxy_Fails xmlrpclib ServerProxy This

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import xmlrpclib
class MyServerProxy_Fails(xmlrpclib.ServerProxy):
# This is exact copy from the original __init__() except for added "xmlrpclib"
def __init__(self, uri, transport=None, encoding=None, verbose=0,
allow_none=0, use_datetime=0):
# establish a "logical" server connection
# get the url
import urllib
type, uri = urllib.splittype(uri)
if type not in ("http", "https"):
raise IOError, "unsupported XML-RPC protocol"
self.__host, self.__handler = urllib.splithost(uri)
if not self.__handler:
self.__handler = "/RPC2"
if transport is None:
if type == "https":
transport = xmlrpclib.SafeTransport(use_datetime=use_datetime)
else:
transport = xmlrpclib.Transport(use_datetime=use_datetime)
self.__transport = transport
self.__encoding = encoding
self.__verbose = verbose
self.__allow_none = allow_none
class MyServerProxy_Works(xmlrpclib.ServerProxy):
def __init__(self, uri, transport=None, encoding=None, verbose=0,
allow_none=0, use_datetime=0):
xmlrpclib.ServerProxy.__init__(self, uri, transport, encoding,
verbose, allow_none, use_datetime)
server = MyServerProxy_Works('http://time.xmlrpc.com/RPC2')
print server.currentTime.getCurrentTime()
# Why?
server = MyServerProxy_Fails('http://time.xmlrpc.com/RPC2')
print server.currentTime.getCurrentTime()