#from sfa.util.faults import SfaNotImplemented, SfaAPIError, SfaInvalidAPIMethod, SfaFault
from sfa.util.faults import SfaInvalidAPIMethod, SfaAPIError, SfaFault
from sfa.util.sfalogging import logger
#from sfa.util.faults import SfaNotImplemented, SfaAPIError, SfaInvalidAPIMethod, SfaFault
from sfa.util.faults import SfaInvalidAPIMethod, SfaAPIError, SfaFault
from sfa.util.sfalogging import logger
# [#x7F-#x84], [#x86-#x9F], [#xFDD0-#xFDDF]
invalid_xml_ascii = map(chr, range(0x0, 0x8) + [0xB, 0xC] + range(0xE, 0x1F))
# [#x7F-#x84], [#x86-#x9F], [#xFDD0-#xFDDF]
invalid_xml_ascii = map(chr, range(0x0, 0x8) + [0xB, 0xC] + range(0xE, 0x1F))
"""
xmlrpclib does not handle invalid 7-bit control characters. This
function augments xmlrpclib.escape, which by default only replaces
"""
xmlrpclib does not handle invalid 7-bit control characters. This
function augments xmlrpclib.escape, which by default only replaces
def xmlrpclib_dump(self, value, write):
"""
xmlrpclib cannot marshal instances of subclasses of built-in
def xmlrpclib_dump(self, value, write):
"""
xmlrpclib cannot marshal instances of subclasses of built-in
-xmlrpclib.Marshaller._Marshaller__dump = xmlrpclib_dump
+# Note: not quite sure if this will still cause
+# the expected behaviour under python3
+xmlrpc_client.Marshaller._Marshaller__dump = xmlrpclib_dump
+
def callable(self, method):
"""
Return a new instance of the specified method.
"""
# Look up method
if method not in self.methods:
def callable(self, method):
"""
Return a new instance of the specified method.
"""
# Look up method
if method not in self.methods:
- module = __import__(self.methods_module.__name__ + "." + method, globals(), locals(), [classname])
+ module = __import__(self.methods_module.__name__ +
+ "." + method, globals(), locals(), [classname])
callablemethod = getattr(module, classname)(self)
return getattr(module, classname)(self)
except (ImportError, AttributeError):
callablemethod = getattr(module, classname)(self)
return getattr(module, classname)(self)
except (ImportError, AttributeError):
def call(self, source, method, *args):
"""
def call(self, source, method, *args):
"""
def handle(self, source, data, method_map):
"""
Handle an XML-RPC or SOAP request from the specified source.
"""
# Parse request into method name and arguments
try:
def handle(self, source, data, method_map):
"""
Handle an XML-RPC or SOAP request from the specified source.
"""
# Parse request into method name and arguments
try:
- interface = xmlrpclib
- self.protocol = 'xmlrpclib'
- (args, method) = xmlrpclib.loads(data)
- if method_map.has_key(method):
+ interface = xmlrpc_client
+ self.protocol = 'xmlrpc'
+ (args, method) = xmlrpc_client.loads(data)
+ if method in method_map:
- (r, header, body, attrs) = parseSOAPRPC(data, header = 1, body = 1, attrs = 1)
+ (r, header, body, attrs) = parseSOAPRPC(
+ data, header=1, body=1, attrs=1)
- self.logger.log_exc("XmlrpcApi.handle has caught Exception")
- except Exception, fault:
+ self.logger.log_exc("XmlrpcApi.handle has caught Exception")
+ except Exception as fault:
def prepare_response(self, result, method=""):
"""
convert result to a valid xmlrpc or soap response
def prepare_response(self, result, method=""):
"""
convert result to a valid xmlrpc or soap response
- response = xmlrpclib.dumps(result, methodresponse = True, encoding = self.encoding, allow_none = 1)
+ response = xmlrpc_client.dumps(
+ result, methodresponse=True, encoding=self.encoding, allow_none=1)
elif self.protocol == 'soap':
if isinstance(result, Exception):
elif self.protocol == 'soap':
if isinstance(result, Exception):
- result = faultParameter(NS.ENV_T + ":Server", "Method Failed", method)
- result._setDetail("Fault %d: %s" % (result.faultCode, result.faultString))
+ result = faultParameter(
+ NS.ENV_T + ":Server", "Method Failed", method)
+ result._setDetail("Fault %d: %s" %
+ (result.faultCode, result.faultString))