Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes | Private Attributes
xmlrpc.client.Unmarshaller Class Reference

XML-RPC unmarshaller. More...

List of all members.

Public Member Functions

def __init__
def close
def getmethodname
def xml
def start
def data
def end
def end_dispatch
def end_nil
def end_boolean
def end_int
def end_double
def end_string
def end_array
def end_struct
def end_base64
def end_dateTime
def end_value
def end_params
def end_fault
def end_methodName

Public Attributes

 append

Static Public Attributes

dictionary dispatch = {}

Private Attributes

 _type
 _stack
 _marks
 _data
 _methodname
 _encoding
 _use_datetime
 _value

Detailed Description

XML-RPC unmarshaller.

See also:
loads
Unmarshal an XML-RPC response, based on incoming XML event
messages (start, data, end).  Call close() to get the resulting
data structure.

Note that this reader is fairly tolerant, and gladly accepts bogus
XML-RPC data without complaining (but not bogus XML).

Definition at line 638 of file client.py.


Constructor & Destructor Documentation

def xmlrpc.client.Unmarshaller.__init__ (   self,
  use_datetime = False 
)

Definition at line 650 of file client.py.

00650 
00651     def __init__(self, use_datetime=False):
00652         self._type = None
00653         self._stack = []
00654         self._marks = []
00655         self._data = []
00656         self._methodname = None
00657         self._encoding = "utf-8"
00658         self.append = self._stack.append
00659         self._use_datetime = use_datetime
00660         if use_datetime and not datetime:
00661             raise ValueError("the datetime module is not available")

Here is the caller graph for this function:


Member Function Documentation

Definition at line 662 of file client.py.

00662 
00663     def close(self):
00664         # return response tuple and target method
00665         if self._type is None or self._marks:
00666             raise ResponseError()
00667         if self._type == "fault":
00668             raise Fault(**self._stack[0])
00669         return tuple(self._stack)

Here is the caller graph for this function:

def xmlrpc.client.Unmarshaller.data (   self,
  text 
)

Definition at line 687 of file client.py.

00687 
00688     def data(self, text):
00689         self._data.append(text)

Here is the caller graph for this function:

def xmlrpc.client.Unmarshaller.end (   self,
  tag 
)

Definition at line 690 of file client.py.

00690 
00691     def end(self, tag):
00692         # call the appropriate end tag handler
00693         try:
00694             f = self.dispatch[tag]
00695         except KeyError:
00696             pass # unknown tag ?
00697         else:
00698             return f(self, "".join(self._data))

Here is the caller graph for this function:

def xmlrpc.client.Unmarshaller.end_array (   self,
  data 
)

Definition at line 751 of file client.py.

00751 
00752     def end_array(self, data):
00753         mark = self._marks.pop()
00754         # map arrays to Python lists
00755         self._stack[mark:] = [self._stack[mark:]]
        self._value = 0
def xmlrpc.client.Unmarshaller.end_base64 (   self,
  data 
)

Definition at line 769 of file client.py.

00769 
00770     def end_base64(self, data):
00771         value = Binary()
00772         value.decode(data.encode("ascii"))
00773         self.append(value)
        self._value = 0
def xmlrpc.client.Unmarshaller.end_boolean (   self,
  data 
)

Definition at line 721 of file client.py.

00721 
00722     def end_boolean(self, data):
00723         if data == "0":
00724             self.append(False)
00725         elif data == "1":
00726             self.append(True)
00727         else:
00728             raise TypeError("bad boolean value")
        self._value = 0
def xmlrpc.client.Unmarshaller.end_dateTime (   self,
  data 
)

Definition at line 776 of file client.py.

00776 
00777     def end_dateTime(self, data):
00778         value = DateTime()
00779         value.decode(data)
00780         if self._use_datetime:
00781             value = _datetime_type(data)
        self.append(value)

Here is the call graph for this function:

def xmlrpc.client.Unmarshaller.end_dispatch (   self,
  tag,
  data 
)

Definition at line 702 of file client.py.

00702 
00703     def end_dispatch(self, tag, data):
00704         # dispatch data
00705         try:
00706             f = self.dispatch[tag]
00707         except KeyError:
00708             pass # unknown tag ?
00709         else:
00710             return f(self, data)

def xmlrpc.client.Unmarshaller.end_double (   self,
  data 
)

Definition at line 738 of file client.py.

00738 
00739     def end_double(self, data):
00740         self.append(float(data))
        self._value = 0
def xmlrpc.client.Unmarshaller.end_fault (   self,
  data 
)

Definition at line 795 of file client.py.

00795 
00796     def end_fault(self, data):
        self._type = "fault"
def xmlrpc.client.Unmarshaller.end_int (   self,
  data 
)

Definition at line 731 of file client.py.

00731 
00732     def end_int(self, data):
00733         self.append(int(data))
        self._value = 0
def xmlrpc.client.Unmarshaller.end_methodName (   self,
  data 
)

Definition at line 799 of file client.py.

00799 
00800     def end_methodName(self, data):
00801         if self._encoding:
00802             data = data.decode(self._encoding)
00803         self._methodname = data
        self._type = "methodName" # no params
def xmlrpc.client.Unmarshaller.end_nil (   self,
  data 
)

Definition at line 716 of file client.py.

00716 
00717     def end_nil (self, data):
00718         self.append(None)
        self._value = 0
def xmlrpc.client.Unmarshaller.end_params (   self,
  data 
)

Definition at line 791 of file client.py.

00791 
00792     def end_params(self, data):
        self._type = "params"
def xmlrpc.client.Unmarshaller.end_string (   self,
  data 
)

Definition at line 743 of file client.py.

00743 
00744     def end_string(self, data):
00745         if self._encoding:
00746             data = data.decode(self._encoding)
00747         self.append(data)
        self._value = 0

Here is the caller graph for this function:

def xmlrpc.client.Unmarshaller.end_struct (   self,
  data 
)

Definition at line 758 of file client.py.

00758 
00759     def end_struct(self, data):
00760         mark = self._marks.pop()
00761         # map structs to Python dictionaries
00762         dict = {}
00763         items = self._stack[mark:]
00764         for i in range(0, len(items), 2):
00765             dict[items[i]] = items[i+1]
00766         self._stack[mark:] = [dict]
        self._value = 0
def xmlrpc.client.Unmarshaller.end_value (   self,
  data 
)

Definition at line 784 of file client.py.

00784 
00785     def end_value(self, data):
00786         # if we stumble upon a value element with no internal
00787         # elements, treat it as a string element
00788         if self._value:
            self.end_string(data)

Here is the call graph for this function:

Definition at line 670 of file client.py.

00670 
00671     def getmethodname(self):
00672         return self._methodname

def xmlrpc.client.Unmarshaller.start (   self,
  tag,
  attrs 
)

Definition at line 680 of file client.py.

00680 
00681     def start(self, tag, attrs):
00682         # prepare to handle this element
00683         if tag == "array" or tag == "struct":
00684             self._marks.append(len(self._stack))
00685         self._data = []
00686         self._value = (tag == "value")

Here is the caller graph for this function:

def xmlrpc.client.Unmarshaller.xml (   self,
  encoding,
  standalone 
)

Definition at line 676 of file client.py.

00676 
00677     def xml(self, encoding, standalone):
00678         self._encoding = encoding
00679         # FIXME: assert standalone == 1 ???

Here is the caller graph for this function:


Member Data Documentation

Definition at line 654 of file client.py.

Definition at line 656 of file client.py.

Definition at line 653 of file client.py.

Definition at line 655 of file client.py.

Definition at line 652 of file client.py.

Definition at line 651 of file client.py.

Definition at line 658 of file client.py.

Definition at line 685 of file client.py.

Definition at line 657 of file client.py.

Definition at line 714 of file client.py.


The documentation for this class was generated from the following file: