[Zope3-checkins] SVN: Zope3/branches/3.3/ - Fixed issue 550: added adapter for datetime.datetime for xmlrpc premarshalling$

Christian Theune cvs-admin at zope.org
Sun Jun 18 22:01:25 EDT 2006


Log message for revision 68742:
   - Fixed issue 550: added adapter for datetime.datetime for xmlrpc premarshalling$
  

Changed:
  U   Zope3/branches/3.3/doc/CHANGES.txt
  U   Zope3/branches/3.3/src/zope/publisher/configure.zcml
  U   Zope3/branches/3.3/src/zope/publisher/xmlrpc.py
  U   Zope3/branches/3.3/src/zope/publisher/xmlrpc.txt

-=-
Modified: Zope3/branches/3.3/doc/CHANGES.txt
===================================================================
--- Zope3/branches/3.3/doc/CHANGES.txt	2006-06-19 02:00:50 UTC (rev 68741)
+++ Zope3/branches/3.3/doc/CHANGES.txt	2006-06-19 02:01:22 UTC (rev 68742)
@@ -10,6 +10,9 @@
 
     Bugfixes
 
+      - Fixed issue 550: Added adapter for datetime.datetime for xmlrpc
+        premarshalling$
+
       - Fixed issue 633: Boston skin has logo slot now
 
       - Fixed issue 575: Inconsistent raising of TraversalError

Modified: Zope3/branches/3.3/src/zope/publisher/configure.zcml
===================================================================
--- Zope3/branches/3.3/src/zope/publisher/configure.zcml	2006-06-19 02:00:50 UTC (rev 68741)
+++ Zope3/branches/3.3/src/zope/publisher/configure.zcml	2006-06-19 02:01:22 UTC (rev 68742)
@@ -21,6 +21,11 @@
       />
 
   <adapter
+      factory=".xmlrpc.PythonDateTimePreMarshaller"
+      for="datetime.datetime"
+      />
+
+  <adapter
       factory=".xmlrpc.DictPreMarshaller"
       for="dict"
       />

Modified: Zope3/branches/3.3/src/zope/publisher/xmlrpc.py
===================================================================
--- Zope3/branches/3.3/src/zope/publisher/xmlrpc.py	2006-06-19 02:00:50 UTC (rev 68741)
+++ Zope3/branches/3.3/src/zope/publisher/xmlrpc.py	2006-06-19 02:01:22 UTC (rev 68742)
@@ -199,6 +199,12 @@
     def __call__(self):
         return xmlrpclib.DateTime(self.data.value)
 
+class PythonDateTimePreMarshaller(PreMarshallerBase):
+    """Pre-marshaller for datetime.datetime"""
+
+    def __call__(self):
+        return xmlrpclib.DateTime(self.data.isoformat())
+
 def premarshal(data):
     """Premarshal data before handing it to xmlrpclib for marhalling
 

Modified: Zope3/branches/3.3/src/zope/publisher/xmlrpc.txt
===================================================================
--- Zope3/branches/3.3/src/zope/publisher/xmlrpc.txt	2006-06-19 02:00:50 UTC (rev 68741)
+++ Zope3/branches/3.3/src/zope/publisher/xmlrpc.txt	2006-06-19 02:01:22 UTC (rev 68742)
@@ -48,3 +48,14 @@
   >>> type(stripped_fault) is Proxy
   False
 
+Standard python datetime objects are also handled:
+
+  >>> import datetime
+  >>> sample = datetime.datetime(2006,06,17,21,41,00)
+  >>> stripped_date = premarshal(sample)
+  >>> isinstance(stripped_date, datetime.datetime)
+  False
+  >>> isinstance(stripped_date, xmlrpclib.DateTime)
+  True
+
+



More information about the Zope3-Checkins mailing list