[Zope-dev] xmlrpc OverflowError fault

Willi Langenberger wlang at wu-wien.ac.at
Sat May 13 10:24:51 EDT 2006


Trying to get a Zope DateTime object (as dictionary value) via xml-rpc
gives on OverflowError! You can try it yourself:

(I used a freshly installed Zope-2.9.3 [with python-2.4.3] on Linux
FC3; but other versions should behave equally.)

Add a Python Script in the Zope OFS root folder:

  return {'root_modification_time': container.bobobase_modification_time()}

The www request returns:

  {'root_modification_time': DateTime('2006/05/13 14:33:12.445 GMT+2')}

But the XML-RPC returns:

  xmlrpclib.Fault: (-1, 'Unexpected Zope exception:
   exceptions.OverflowError - long int exceeds XML-RPC limits'

The reason for this is, that the DateTime object is treated as a normal
instance by xmlrpclib, ie __dict__ is marshalled (which, unfortunately,
contains the attribute '_millis', which is usually too big).

It would be better anyway, if Zope DateTime objects would be
marshalled as XML-RPC dates (dateTime.iso8601). Eg like that:

--- xmlrpclib.py.ori    2006-05-13 13:29:45.606954800 +0200
+++ xmlrpclib.py.wlang  2006-05-13 13:32:45.923542512 +0200
@@ -701,10 +701,15 @@
 
     def dump_instance(self, value, write):
         # check for special wrappers
+        import DateTime as ZopeDateTime
         if value.__class__ in WRAPPERS:
             self.write = write
             value.encode(self)
             del self.write
+        elif value.__class__ == ZopeDateTime.DateTime:
+            self.write = write
+            DateTime(value).encode(self)
+            del self.write
         else:
             # store instance attributes as a struct (really?)
             self.dump_struct(value.__dict__, write)

However, this would modify xmlrpclib.py from the python distribution,
wich is plain ugly.

Can anyone think of a better solution? Is it possible to change
xmlrpclib.WRAPPERS from Zope, but leave python's xmlrpclib.py
unaffected?


\wlang{}

-- 
Willi.Langenberger at wu-wien.ac.at                Fax: +43/1/31336/9207
Zentrum fuer Informatikdienste, Wirtschaftsuniversitaet Wien, Austria


More information about the Zope-Dev mailing list