[Freeipa-devel] [PATCH] jderose 028 Lossless datetime round-trip

Jason Gerard DeRose jderose at redhat.com
Thu Dec 3 17:14:38 UTC 2009


On Thu, 2009-12-03 at 11:56 -0500, Rob Crittenden wrote:
> Jason Gerard DeRose wrote:
> > As per John's request, this patch allows lossless round-tripping of
> > Python datetime.datetime objects.
> > 
> > Unfortunately, the xmlrpclib dumps() and loads() functions use funny
> > wrapper objects like xmlrpclib.DateTime rather than directly serializing
> > to/from standard Python types like datetime.datetime.  This makes
> > lossless round-tripping pretty cumbersome to implement.
> > 
> > Doing a loads(foo, use_datetime=True) would work, but the `use_datetime`
> > kwarg is only available in Python2.5 and newer, so I instead extended my
> > xml_wrap() and xml_unwrap() functions.
> >
> 
> What should this do it if the incoming DateTime value is not parsed 
> correctly by datetime.datetime()?
> 
> rob

I don't believe this can happen... DateTime and datetime are both stored
in a time.struct_time, so if the XML contains an invalid date, things
will have already blown-up when the DateTime was created.  I image
xmlrpclib will raise a ProtocolError error, but I can add a test for
this.




More information about the Freeipa-devel mailing list