iro/view/xmlrpc.py
branchdevel
changeset 110 601fc908d9f1
parent 93 ee10253258ad
child 112 ea437d1e7b65
equal deleted inserted replaced
109:935b5fcaf152 110:601fc908d9f1
    16 import logging
    16 import logging
    17 
    17 
    18 
    18 
    19 from ..controller.viewinterface import Interface
    19 from ..controller.viewinterface import Interface
    20 
    20 
       
    21 from ..error import InterfaceException, ValidateException
    21 
    22 
    22 class TwistedInterface(Interface):
    23 class TwistedInterface(Interface):
    23     
    24     
    24     def __init__(self):
    25     def __init__(self):
    25         Interface.__init__(self)
    26         Interface.__init__(self)
    43     def __init__(self):
    44     def __init__(self):
    44         xmlrpc.XMLRPC.__init__(self) 
    45         xmlrpc.XMLRPC.__init__(self) 
    45         TwistedInterface.__init__(self)
    46         TwistedInterface.__init__(self)
    46     
    47     
    47     def lookupProcedure(self, procedurePath):
    48     def lookupProcedure(self, procedurePath):
    48         logging.debug("lookupProcedure('%s')"%procedurePath)
       
    49         if procedurePath not in self.listProcedures():
    49         if procedurePath not in self.listProcedures():
    50             raise xmlrpc.NoSuchFunction(self.NOT_FOUND,
    50             raise xmlrpc.NoSuchFunction(self.NOT_FOUND,
    51                         "procedure %s not found" % procedurePath)
    51                         "procedure %s not found" % procedurePath)
    52         try:
    52         try:
    53             return getattr(self,procedurePath)
    53             return getattr(self,procedurePath)
    54         except KeyError:
    54         except KeyError:
    55             raise xmlrpc.NoSuchFunction(self.NOT_FOUND,
    55             raise xmlrpc.NoSuchFunction(self.NOT_FOUND,
    56                         "procedure %s not found" % procedurePath)
    56                         "procedure %s not found" % procedurePath)
       
    57 
       
    58     def _ebRender(self, failure):
       
    59         if isinstance(failure.value, InterfaceException):
       
    60             return xmlrpc.Fault(failure.value.code, failure.value.msg)
       
    61         if isinstance(failure.value, ValidateException):
       
    62             return xmlrpc.Fault(failure.value.code, failure.value.msg)
       
    63         return xmlrpc.XMLRPC._ebRender(self, failure)
       
    64 
    57 
    65 
    58 class SOAPInterface(TwistedInterface,soap.SOAPPublisher): 
    66 class SOAPInterface(TwistedInterface,soap.SOAPPublisher): 
    59     def __init__(self):
    67     def __init__(self):
    60         soap.SOAPPublisher.__init__(self) 
    68         soap.SOAPPublisher.__init__(self) 
    61         TwistedInterface.__init__(self)
    69         TwistedInterface.__init__(self)