xmlrpclib and mx.DateTime

Ashley Walsh ashleywalsh at synengco.com
Tue Jan 29 22:46:30 EST 2002

On Tue, 29 Jan 2002 17:11:33 -0800, Chuck Esterbrook
<ChuckEsterbrook at StockAlerts.com> wrote:

>Does anyone have a patch lying about to make xmlrpclib and mx.DateTime
>play nice together?
>xmlrpclib raises an exception when it tries to "xml marshal" an
>mx.DateTime. I'm not the first to run into this and I'm wondering if
>anyone has "fixed it" already.

You can modify the Marshaller and Unmarshaller in xmlrpclib like this:

import xmlrpclib
import mx.DateTime

# Extend xmlrpclib.Marshaller to mx.DateTime.DateTime type

def dump_datetime(self, value):
               % xmlrpclib.escape(str(value)))

xmlrpclib.Marshaller.dispatch[mx.DateTime.DateTimeType] = dump_datetime

# modify xmlrpclib.Unmarshaller to generate
# mx.DateTime.DateTime instances

def end_dateTime(self, join=string.join):
    self.append(mx.DateTime.DateTimeFrom(join(self._data, "")))
    self._value = 0

xmlrpclib.Unmarshaller.end_dateTime = end_dateTime
xmlrpclib.Unmarshaller.dispatch["dateTime.iso8601"] = end_dateTime


More information about the Python-list mailing list