Manage microseconds in JSON-RPC and XML-RPC

review3551002
This commit is contained in:
Cédric Krier
2014-03-15 10:36:20 +01:00
parent 88a4bce42d
commit 64421ff64f
3 changed files with 9 additions and 3 deletions
+1
View File
@@ -1,3 +1,4 @@
* Manage microseconds in JSON-RPC and XML-RPC
* Remove Sha field
* Add password widget
* Add Len to PYSON
+5 -2
View File
@@ -37,11 +37,12 @@ def object_hook(dct):
if '__class__' in dct:
if dct['__class__'] == 'datetime':
return datetime.datetime(dct['year'], dct['month'], dct['day'],
dct['hour'], dct['minute'], dct['second'])
dct['hour'], dct['minute'], dct['second'], dct['microsecond'])
elif dct['__class__'] == 'date':
return datetime.date(dct['year'], dct['month'], dct['day'])
elif dct['__class__'] == 'time':
return datetime.time(dct['hour'], dct['minute'], dct['second'])
return datetime.time(dct['hour'], dct['minute'], dct['second'],
dct['microsecond'])
elif dct['__class__'] == 'buffer':
return buffer(base64.decodestring(dct['base64']))
elif dct['__class__'] == 'Decimal':
@@ -66,6 +67,7 @@ class JSONEncoder(json.JSONEncoder):
'hour': obj.hour,
'minute': obj.minute,
'second': obj.second,
'microsecond': obj.microsecond,
}
return {'__class__': 'date',
'year': obj.year,
@@ -77,6 +79,7 @@ class JSONEncoder(json.JSONEncoder):
'hour': obj.hour,
'minute': obj.minute,
'second': obj.second,
'microsecond': obj.microsecond,
}
elif isinstance(obj, buffer):
return {'__class__': 'buffer',
+3 -1
View File
@@ -49,6 +49,7 @@ def dump_time(self, value, write):
'hour': value.hour,
'minute': value.minute,
'second': value.second,
'microsecond': value.microsecond,
}
self.dump_struct(value, write)
@@ -84,7 +85,8 @@ def end_struct(self, data):
if dct['__class__'] == 'date':
dct = datetime.date(dct['year'], dct['month'], dct['day'])
elif dct['__class__'] == 'time':
dct = datetime.time(dct['hour'], dct['minute'], dct['second'])
dct = datetime.time(dct['hour'], dct['minute'], dct['second'],
dct['microsecond'])
elif dct['__class__'] == 'Decimal':
dct = Decimal(dct['decimal'])
self._stack[mark:] = [dct]