uri [,options] -> a logical connection to an XML-RPC server uri is the connection point on the server, given as scheme://host/target. The standard implementation always supports the "http" scheme. If SSL socket support is available (Python 2.0), it also supports "https"
| 1400 | # @see Transport |
| 1401 | |
| 1402 | class ServerProxy: |
| 1403 | """uri [,options] -> a logical connection to an XML-RPC server |
| 1404 | |
| 1405 | uri is the connection point on the server, given as |
| 1406 | scheme://host/target. |
| 1407 | |
| 1408 | The standard implementation always supports the "http" scheme. If |
| 1409 | SSL socket support is available (Python 2.0), it also supports |
| 1410 | "https". |
| 1411 | |
| 1412 | If the target part and the slash preceding it are both omitted, |
| 1413 | "/RPC2" is assumed. |
| 1414 | |
| 1415 | The following options can be given as keyword arguments: |
| 1416 | |
| 1417 | transport: a transport factory |
| 1418 | encoding: the request encoding (default is UTF-8) |
| 1419 | |
| 1420 | All 8-bit strings passed to the server proxy are assumed to use |
| 1421 | the given encoding. |
| 1422 | """ |
| 1423 | |
| 1424 | def __init__(self, uri, transport=None, encoding=None, verbose=False, |
| 1425 | allow_none=False, use_datetime=False, use_builtin_types=False, |
| 1426 | *, headers=(), context=None): |
| 1427 | # establish a "logical" server connection |
| 1428 | |
| 1429 | # get the url |
| 1430 | p = urllib.parse.urlsplit(uri) |
| 1431 | if p.scheme not in ("http", "https"): |
| 1432 | raise OSError("unsupported XML-RPC protocol") |
| 1433 | self.__host = p.netloc |
| 1434 | self.__handler = urllib.parse.urlunsplit(["", "", *p[2:]]) |
| 1435 | if not self.__handler: |
| 1436 | self.__handler = "/RPC2" |
| 1437 | |
| 1438 | if transport is None: |
| 1439 | if p.scheme == "https": |
| 1440 | handler = SafeTransport |
| 1441 | extra_kwargs = {"context": context} |
| 1442 | else: |
| 1443 | handler = Transport |
| 1444 | extra_kwargs = {} |
| 1445 | transport = handler(use_datetime=use_datetime, |
| 1446 | use_builtin_types=use_builtin_types, |
| 1447 | headers=headers, |
| 1448 | **extra_kwargs) |
| 1449 | self.__transport = transport |
| 1450 | |
| 1451 | self.__encoding = encoding or 'utf-8' |
| 1452 | self.__verbose = verbose |
| 1453 | self.__allow_none = allow_none |
| 1454 | |
| 1455 | def __close(self): |
| 1456 | self.__transport.close() |
| 1457 | |
| 1458 | def __request(self, methodname, params): |
| 1459 | # call a method on the remote server |