xmlrpclib and SimpleXMLRPCServer questions

xkenneth xkenneth at gmail.com
Wed Sep 12 15:51:44 EDT 2007


So i've been trying to set up a simple server and client through
XMLRPC in python.

Here's my code:

SERVER

import SimpleXMLRPCServer


class DataServer:
    def __init__(self):
        pass

    def test(self,test):
        self.this = test

    def show(self):
        print self.this

server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8005))
server.register_instance(DataServer())
server.serve_forever()

CLIENT
import xmlrpclib
server = xmlrpclib.Server('http://localhost:8005')
server.test(5)
server.show()


Now, I'm getting the most odd callback from the client side:

>>> server.show()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/
lib/python2.4/xmlrpclib.py", line 1096, in __call__
    return self.__send(self.__name, args)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/
lib/python2.4/xmlrpclib.py", line 1383, in __request
    verbose=self.__verbose
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/
lib/python2.4/xmlrpclib.py", line 1147, in request
    return self._parse_response(h.getfile(), sock)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/
lib/python2.4/xmlrpclib.py", line 1286, in _parse_response
    return u.close()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/
lib/python2.4/xmlrpclib.py", line 744, in close
    raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 1: 'exceptions.TypeError:cannot marshal None
unless allow_none is enabled'>

What is causing this? The server recieves the data and seems to
respond properly regardless of this error, so by all means i can
always catch it, but that sounds stupid.

Here I can verify the server process is indeed recieving the data
(calling the client with two different values):

localhost - - [12/Sep/2007 14:35:18] "POST /RPC2 HTTP/1.0" 200 -
5
localhost - - [12/Sep/2007 14:35:41] "POST /RPC2 HTTP/1.0" 200 -
10

Looking at the documentation:

class SimpleXMLRPCServer(	addr[, requestHandler[,
logRequests[allow_none[, encoding]]]])

I'm not sure how to specify the allow_none value or it's type, how can
i find out more?

Thanks for the help!

Regards,
Ken




More information about the Python-list mailing list