[Zope-dev] Re: xmlrpc OverflowError fault

Willi Langenberger wlang at wu-wien.ac.at
Mon May 15 17:33:43 EDT 2006


According to Tres Seaver:
> > 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'
>
> A monkeypatch of the module should work fine, as the 'WRAPPERS' object
> is looked up as a global at each use.  If anybody *else* imports it
> using 'from xmlrpc import WRAPPERS', then they won't see the new
> registration after the monkeypatch, because 'WRAPPERS' is a tuple, and
> must therefore be replaced, rather than mutated.

Tres, thanks for the hint! I updated my patch in the collector
(http://www.zope.org/Collectors/Zope/2109). Is there chance to get
this in the Zope distribution?

Thanks,

\wlang{}


$ cat xmlrpc-datetime.patch
--- DateTime/DateTime.py.ori	2006-05-12 13:53:46.000000000 +0200
+++ DateTime/DateTime.py	2006-05-15 23:15:40.485825640 +0200
@@ -1805,6 +1805,11 @@
         d1 = (( d4 - L) % 365) + L
         return d1/7 + 1
 
+    # wlang, 2006-05: make DateTime instances marshallable via xml-rpc
+    def encode(self, out):
+        out.write("<value><dateTime.iso8601>")
+        out.write(self.ISO8601())
+        out.write("</dateTime.iso8601></value>\n")
 
 class strftimeFormatter:
 
--- ZPublisher/xmlrpc.py.ori	2006-05-12 13:53:45.000000000 +0200
+++ ZPublisher/xmlrpc.py	2006-05-15 23:15:05.055211912 +0200
@@ -23,6 +23,10 @@
 import sys, types
 from HTTPResponse import HTTPResponse
 import xmlrpclib
+# wlang, 2006-05: monkeypatch to make DateTime marshallable via xml-rpc
+from DateTime import DateTime
+xmlrpclib.WRAPPERS = xmlrpclib.WRAPPERS + (DateTime,)
+
 
 from zExceptions import Unauthorized


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