allow_none=True in SimpleXMLRPCServer

D

Daniel Crespo

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
 
D

Dody Suria Wijaya

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...
 
D

Daniel Crespo

Thank you very much! I will try it as soon as possible, and write you
back with my results.

Best regards

Daniel
 
D

Daniel Crespo

Hi Dody!

It works perfect! Now, I want the SimpleXMLRPCServer.py not to be on
the same directory, but in my /lib directory. I tried it, but it seems
that the module loads from python24/ first. How can I change this?

Thank you!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,274
Messages
2,571,366
Members
48,057
Latest member
AntoineGre

Latest Threads

Top