ProtocolErrors raise a (code, message) tuple instead of a string as per request in...
[invirt/packages/python-jsonrpclib.git] / jsonrpclib / SimpleJSONRPCServer.py
index ae41f93..f049f85 100644 (file)
@@ -92,7 +92,7 @@ class SimpleJSONRPCDispatcher(SimpleXMLRPCServer.SimpleXMLRPCDispatcher):
                     return self.instance._dispatch(method, params)
                 else:
                     try:
-                        func = resolve_dotted_attribute(
+                        func = SimpleXMLRPCServer.resolve_dotted_attribute(
                             self.instance,
                             method,
                             True
@@ -159,8 +159,15 @@ class SimpleJSONRPCServer(SocketServer.TCPServer,
                  logRequests=True, encoding=None, bind_and_activate=True):
         self.logRequests = logRequests
         SimpleJSONRPCDispatcher.__init__(self, encoding)
-        SocketServer.TCPServer.__init__(self, addr, requestHandler,
-                                        bind_and_activate)
+        # TCPServer.__init__ has an extra parameter on 2.6+, so
+        # check Python version and decide on how to call it
+        vi = sys.version_info
+        # if python 2.5 and lower
+        if vi[0] < 3 and vi[1] < 6:
+            SocketServer.TCPServer.__init__(self, addr, requestHandler)
+        else:
+            SocketServer.TCPServer.__init__(self, addr, requestHandler,
+                bind_and_activate)
         if fcntl is not None and hasattr(fcntl, 'FD_CLOEXEC'):
             flags = fcntl.fcntl(self.fileno(), fcntl.F_GETFD)
             flags |= fcntl.FD_CLOEXEC