simplexmlrpcserver and allow_none

Laszlo Nagy gandalf at designaproduct.biz
Thu Jun 8 11:56:36 EDT 2006


Thomas Bellman írta:
> Laszlo Nagy <gandalf at designaproduct.biz> wrote:
>
>   
>> I ran in the same problem again. Many others have the same problem. Just 
>> Google for this: "SimpleXMLRPCServer allow_none site:python.org".
>> Looks like the 'allow_none' patch was commited to trunk on 2005 Dec ( 
>> http://mail.python.org/pipermail/python-checkins/2005-December/048289.html )
>>     
>
>   
>> I just upgraded to Python 2.4.3 (it was released on March 29, 2006) and 
>> SimpleXMLRPCServer.py still has the old code.
>> I can work around this by coping the whole file into  a new file and 
>> patch it, but I hate to do that.
>> I wonder why it has not been commited to the standard library yet. Does 
>> anyone know if it will be in the next bugfix release?
>>     
>
> Fredrik has already answered your specific question, but while
> waiting for 2.5, another way to work around it is to do:
>
>     import xmlrpclib
>     # WARNING: Dirty hack below.
>     #    Replace the dumps() function in xmlrpclib with one that by default
>     #    handles None, so SimpleXMLRPCServer can return None.
>     class _xmldumps(object):
> 	def __init__(self, dumps):
> 	    self.__dumps = (dumps,)
> 	def __call__(self, *args, **kwargs):
> 	    kwargs.setdefault('allow_none', 1)
> 	    return self.__dumps[0](*args, **kwargs)
>     xmlrpclib.dumps = _xmldumps(xmlrpclib.dumps)
>
>     import SimpleXMLRPCServer
>   
Thank you. :-)
I already copied out SimpleXMLRPCServer.py from the 2.5 trunk and it 
seems to be working, but this is much sorter.

   Laszlo




More information about the Python-list mailing list