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


-- 
[EMAIL PROTECTED]                Fax: +43/1/31336/9207
Zentrum fuer Informatikdienste, Wirtschaftsuniversitaet Wien, Austria
_______________________________________________
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )

Reply via email to