Back to index

python3.2  3.2.2
Classes | Functions | Variables
xmlrpc.client Namespace Reference

Classes

class  Error
 Base class for all kinds of client-side errors. More...
class  ProtocolError
 Indicates an HTTP-level protocol error. More...
class  ResponseError
 Indicates a broken XML-RPC response package. More...
class  Fault
 Indicates an XML-RPC fault response package. More...
class  DateTime
class  Binary
class  ExpatParser
class  Marshaller
 XML-RPC marshaller. More...
class  Unmarshaller
 XML-RPC unmarshaller. More...
class  _MultiCallMethod
 Multicall support. More...
class  MultiCallIterator
class  MultiCall
class  GzipDecodedResponse
 Return a decoded file-like object for the gzip encoding as described in RFC 1952. More...
class  _Method
class  Transport
 Standard transport class for XML-RPC over HTTP. More...
class  SafeTransport
 Standard transport class for XML-RPC over HTTPS. More...
class  ServerProxy

Functions

def escape
def _strftime
 Wrapper for XML-RPC DateTime values.
def _datetime
def _datetime_type
def _binary
def getparser
 Create a parser object, and connect it to an unmarshalling instance.
def dumps
def loads
 Convert an XML-RPC packet to a Python object.
def gzip_encode
 Encode a string using the gzip content encoding such as specified by the Content-Encoding: gzip in the HTTP header, as described in RFC 1952.
def gzip_decode
 Decode a string using the gzip content encoding such as specified by the Content-Encoding: gzip in the HTTP header, as described in RFC 1952.

Variables

 gzip = None
 datetime = None
string __version__ = "1.0.1"
int MAXINT = 2
int MININT = 2
int PARSE_ERROR = 32700
int SERVER_ERROR = 32600
int APPLICATION_ERROR = 32500
int SYSTEM_ERROR = 32400
int TRANSPORT_ERROR = 32300
int NOT_WELLFORMED_ERROR = 32700
int UNSUPPORTED_ENCODING = 32701
int INVALID_ENCODING_CHAR = 32702
int INVALID_XMLRPC = 32600
int METHOD_NOT_FOUND = 32601
int INVALID_METHOD_PARAMS = 32602
int INTERNAL_ERROR = 32603
 boolean = Booleanbool
 Backwards compatibility.
tuple WRAPPERS = (DateTime, Binary)
 FastMarshaller = FastParserFastUnmarshallerNone
 Server = ServerProxy
tuple server = ServerProxy("http://time.xmlrpc.com/RPC2")
tuple multi = MultiCall(server)

Function Documentation

def xmlrpc.client._binary (   data) [private]

Definition at line 425 of file client.py.

00425 
00426 def _binary(data):
00427     # decode xml element contents into a Binary structure
00428     value = Binary()
00429     value.decode(data)
00430     return value

def xmlrpc.client._datetime (   data) [private]

Definition at line 365 of file client.py.

00365 
00366 def _datetime(data):
00367     # decode xml element contents into a DateTime structure.
00368     value = DateTime()
00369     value.decode(data)
00370     return value

def xmlrpc.client._datetime_type (   data) [private]

Definition at line 371 of file client.py.

00371 
00372 def _datetime_type(data):
00373     t = time.strptime(data, "%Y%m%dT%H:%M:%S")
00374     return datetime.datetime(*tuple(t)[:6])

Here is the caller graph for this function:

def xmlrpc.client._strftime (   value) [private]

Wrapper for XML-RPC DateTime values.

This converts a time value to the format used by XML-RPC.

The value can be given as a string in the format "yyyymmddThh:mm:ss", as a 9-item time tuple (as returned by time.localtime()), or an integer value (as returned by time.time()). The wrapper uses time.localtime() to convert an integer to a time tuple.

Parameters:
valueThe time, given as an ISO 8601 string, a time tuple, or a integer time value.

Definition at line 272 of file client.py.

00272 
00273 def _strftime(value):
00274     if datetime:
00275         if isinstance(value, datetime.datetime):
00276             return "%04d%02d%02dT%02d:%02d:%02d" % (
00277                 value.year, value.month, value.day,
00278                 value.hour, value.minute, value.second)
00279 
00280     if not isinstance(value, (tuple, time.struct_time)):
00281         if value == 0:
00282             value = time.time()
00283         value = time.localtime(value)
00284 
00285     return "%04d%02d%02dT%02d:%02d:%02d" % value[:6]

Here is the caller graph for this function:

def xmlrpc.client.dumps (   params,
  methodname = None,
  methodresponse = None,
  encoding = None,
  allow_none = False 
)
data [,options] -> marshalled data

Convert an argument tuple or a Fault instance to an XML-RPC
request (or response, if the methodresponse option is used).

In addition to the data object, the following options can be given
as keyword arguments:

    methodname: the method name for a methodCall packet

    methodresponse: true to create a methodResponse packet.
    If this option is used with a tuple, the tuple must be
    a singleton (i.e. it can contain only one element).

    encoding: the packet encoding (default is UTF-8)

All 8-bit strings in the data structure are assumed to use the
packet encoding.  Unicode strings are automatically converted,
where necessary.

Definition at line 920 of file client.py.

00920 
00921           allow_none=False):
00922     """data [,options] -> marshalled data
00923 
00924     Convert an argument tuple or a Fault instance to an XML-RPC
00925     request (or response, if the methodresponse option is used).
00926 
00927     In addition to the data object, the following options can be given
00928     as keyword arguments:
00929 
00930         methodname: the method name for a methodCall packet
00931 
00932         methodresponse: true to create a methodResponse packet.
00933         If this option is used with a tuple, the tuple must be
00934         a singleton (i.e. it can contain only one element).
00935 
00936         encoding: the packet encoding (default is UTF-8)
00937 
00938     All 8-bit strings in the data structure are assumed to use the
00939     packet encoding.  Unicode strings are automatically converted,
00940     where necessary.
00941     """
00942 
00943     assert isinstance(params, (tuple, Fault)), "argument must be tuple or Fault instance"
00944     if isinstance(params, Fault):
00945         methodresponse = 1
00946     elif methodresponse and isinstance(params, tuple):
00947         assert len(params) == 1, "response tuple must be a singleton"
00948 
00949     if not encoding:
00950         encoding = "utf-8"
00951 
00952     if FastMarshaller:
00953         m = FastMarshaller(encoding)
00954     else:
00955         m = Marshaller(encoding, allow_none)
00956 
00957     data = m.dumps(params)
00958 
00959     if encoding != "utf-8":
00960         xmlheader = "<?xml version='1.0' encoding='%s'?>\n" % str(encoding)
00961     else:
00962         xmlheader = "<?xml version='1.0'?>\n" # utf-8 is default
00963 
00964     # standard XML-RPC wrappings
00965     if methodname:
00966         # a method call
00967         if not isinstance(methodname, str):
00968             methodname = methodname.encode(encoding)
00969         data = (
00970             xmlheader,
00971             "<methodCall>\n"
00972             "<methodName>", methodname, "</methodName>\n",
00973             data,
00974             "</methodCall>\n"
00975             )
00976     elif methodresponse:
00977         # a method response, or a fault structure
00978         data = (
00979             xmlheader,
00980             "<methodResponse>\n",
00981             data,
00982             "</methodResponse>\n"
00983             )
00984     else:
00985         return data # return as is
00986     return "".join(data)

Here is the caller graph for this function:

def xmlrpc.client.escape (   s)

Definition at line 155 of file client.py.

00155 
00156 def escape(s):
00157     s = s.replace("&", "&amp;")
00158     s = s.replace("<", "&lt;")
00159     return s.replace(">", "&gt;",)

Here is the caller graph for this function:

def xmlrpc.client.getparser (   use_datetime = False)

Create a parser object, and connect it to an unmarshalling instance.

This function picks the fastest available XML parser.

return A (parser, unmarshaller) tuple.

getparser() -> parser, unmarshaller

Create an instance of the fastest available parser, and attach it
to an unmarshalling object.  Return both objects.

Definition at line 883 of file client.py.

00883 
00884 def getparser(use_datetime=False):
00885     """getparser() -> parser, unmarshaller
00886 
00887     Create an instance of the fastest available parser, and attach it
00888     to an unmarshalling object.  Return both objects.
00889     """
00890     if use_datetime and not datetime:
00891         raise ValueError("the datetime module is not available")
00892     if FastParser and FastUnmarshaller:
00893         if use_datetime:
00894             mkdatetime = _datetime_type
00895         else:
00896             mkdatetime = _datetime
00897         target = FastUnmarshaller(True, False, _binary, mkdatetime, Fault)
00898         parser = FastParser(target)
00899     else:
00900         target = Unmarshaller(use_datetime=use_datetime)
00901         if FastParser:
00902             parser = FastParser(target)
00903         else:
00904             parser = ExpatParser(target)
00905     return parser, target

Here is the call graph for this function:

Here is the caller graph for this function:

def xmlrpc.client.gzip_decode (   data)

Decode a string using the gzip content encoding such as specified by the Content-Encoding: gzip in the HTTP header, as described in RFC 1952.

Parameters:
dataThe encoded data
Returns:
the unencoded data ValueError if data is not correctly coded.
gzip encoded data -> unencoded data

Decode data using the gzip content encoding as described in RFC 1952

Definition at line 1042 of file client.py.

01042 
01043 def gzip_decode(data):
01044     """gzip encoded data -> unencoded data
01045 
01046     Decode data using the gzip content encoding as described in RFC 1952
01047     """
01048     if not gzip:
01049         raise NotImplementedError
01050     f = BytesIO(data)
01051     gzf = gzip.GzipFile(mode="rb", fileobj=f)
01052     try:
01053         decoded = gzf.read()
01054     except IOError:
01055         raise ValueError("invalid data")
01056     f.close()
01057     gzf.close()
01058     return decoded

Here is the caller graph for this function:

def xmlrpc.client.gzip_encode (   data)

Encode a string using the gzip content encoding such as specified by the Content-Encoding: gzip in the HTTP header, as described in RFC 1952.

Parameters:
datathe unencoded data
Returns:
the encoded data
data -> gzip encoded data

Encode data using the gzip content encoding as described in RFC 1952

Definition at line 1018 of file client.py.

01018 
01019 def gzip_encode(data):
01020     """data -> gzip encoded data
01021 
01022     Encode data using the gzip content encoding as described in RFC 1952
01023     """
01024     if not gzip:
01025         raise NotImplementedError
01026     f = BytesIO()
01027     gzf = gzip.GzipFile(mode="wb", fileobj=f, compresslevel=1)
01028     gzf.write(data)
01029     gzf.close()
01030     encoded = f.getvalue()
01031     f.close()
01032     return encoded

Here is the caller graph for this function:

def xmlrpc.client.loads (   data,
  use_datetime = False 
)

Convert an XML-RPC packet to a Python object.

If the XML-RPC packet represents a fault condition, this function raises a Fault exception.

Parameters:
dataAn XML-RPC packet, given as an 8-bit string.
Returns:
A tuple containing the unpacked data, and the method name (None if not present).
See also:
Fault
data -> unmarshalled data, method name

Convert an XML-RPC packet to unmarshalled data plus a method
name (None if not present).

If the XML-RPC packet represents a fault condition, this function
raises a Fault exception.

Definition at line 996 of file client.py.

00996 
00997 def loads(data, use_datetime=False):
00998     """data -> unmarshalled data, method name
00999 
01000     Convert an XML-RPC packet to unmarshalled data plus a method
01001     name (None if not present).
01002 
01003     If the XML-RPC packet represents a fault condition, this function
01004     raises a Fault exception.
01005     """
01006     p, u = getparser(use_datetime=use_datetime)
01007     p.feed(data)
01008     p.close()
01009     return u.close(), u.getmethodname()

Here is the call graph for this function:


Variable Documentation

Definition at line 160 of file client.py.

Definition at line 173 of file client.py.

xmlrpc.client.boolean = Booleanbool

Backwards compatibility.

Definition at line 257 of file client.py.

Definition at line 153 of file client.py.

xmlrpc.client.FastMarshaller = FastParserFastUnmarshallerNone

Definition at line 875 of file client.py.

Definition at line 145 of file client.py.

Definition at line 184 of file client.py.

Definition at line 180 of file client.py.

Definition at line 183 of file client.py.

Definition at line 181 of file client.py.

Definition at line 163 of file client.py.

Definition at line 182 of file client.py.

Definition at line 164 of file client.py.

Definition at line 1476 of file client.py.

Definition at line 178 of file client.py.

Definition at line 171 of file client.py.

Definition at line 1458 of file client.py.

tuple xmlrpc.client.server = ServerProxy("http://time.xmlrpc.com/RPC2")

Definition at line 1468 of file client.py.

Definition at line 172 of file client.py.

Definition at line 174 of file client.py.

Definition at line 175 of file client.py.

Definition at line 179 of file client.py.

Definition at line 431 of file client.py.