"proper"/best way to hack SimpleXmlRpcServer to support datetime?
Russell Warren
russandheather at gmail.com
Sat Jul 19 01:45:32 EDT 2008
I'm running python 2.5.1 and it seems that SimpleXmlRpcServer is not
setup to support the base datetime module in the same way xmlrpclib
has been with "use_datetime". I see that someone (Virgil Dupras) has
recently submitted a fix to address this, but I don't want to patch my
python distro. I want to work around it until the real upgrade comes.
I have a klugey workaround I can just drop in my program that does the
trick, but I'm curious if there is a better way? I have not done that
many monkey patches. I'm also of course interested in someone telling
me I don't need to patch this and I'm just blind to the correct way.
My monkey patch is below...
### HACK HACK HACK ###
## Patching SimpleXmlRpcServer to support datetime (just like
xmlrpclib does)
from SimpleXMLRPCServer import xmlrpclib as _xmlrpclib
_old_loads = _xmlrpclib.loads
def _new_loads(*args, **kwargs):
kwargs["use_datetime"] = True
return _old_loads(*args, **kwargs)
_xmlrpclib.loads = _new_loads
### ENDHACK ENDHACK ###
That works, but are there any better, slicker, more pythonic, more
robust, more interesting, or just plain more fun ways to do it?
More information about the Python-list
mailing list