allow_none=True in SimpleXMLRPCServer
Dody Suria Wijaya
dodysw at gmail.com
Wed Dec 14 11:19:52 EST 2005
Hi, I faced the same same situation, and my quick problem solving was
copying SimpleXMLRPCServer.py to current directory, and "patch" this line:
response = xmlrpclib.dumps(response, methodresponse=1)
into
response = xmlrpclib.dumps(response, methodresponse=1, allow_none=True)
Another better approach is to subclass SimpleXMLRPCDispatcher, and
override just the method that contains above line (copy paste whole
function + fix the parameter), then copy paste the whole class
definition of SimpleXMLRPCServer, but change the mixin to your new
subclass, then give it a new name ie MySimpleXMLRPCServer. Too much
hassle I guess.
Another alternative might be subclassing Marshall class in xmlrpclib.py
override the __init__ as so self.allow_none always True, then set
xmlrpclib.Marshall = yournewsubclass. Ie:
#yourserver.py
import xmlrpclib
class MyMarshall(xmlrpclib.Marshall):
def __init__(self, encoding=None, allow_none=0):
self.memo = {}
self.data = None
self.encoding = encoding
self.allow_none = 1
xmlrpclib.Marshall = MyMarshall
#...might work...
Daniel Crespo wrote:
> Hello,
>
> Does anyone know which methods do I have to override for allowing Nones
> to be accepted and sended from SimpleXMLRPCServer to the client?
>
> Thanks
>
> Daniel
>
More information about the Python-list
mailing list