From 447b6c8847cbe8f52970ae097e7b676d8302aed0 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Wed, 21 Jan 2015 07:51:02 +0100 Subject: [PATCH] TaskResource: Do not serialize annotations as a list in a string --- tasklib/task.py | 10 +++++----- tasklib/tests.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tasklib/task.py b/tasklib/task.py index d386f82..a273815 100644 --- a/tasklib/task.py +++ b/tasklib/task.py @@ -101,12 +101,12 @@ class SerializingObject(object): def serialize_annotations(self, value): value = value if value is not None else [] - serialized_annotations = [annotation.export_data() for annotation in value] - if serialized_annotations: - return '[' + ','.join(serialized_annotations) + ']' - else: - return '' + # This may seem weird, but it's correct, we want to export + # a list of dicts as serialized value + serialized_annotations = [json.loads(annotation.export_data()) + for annotation in value] + return serialized_annotations if serialized_annotations else '' def deserialize_annotations(self, data): return [TaskAnnotation(self, d) for d in data] if data else [] diff --git a/tasklib/tests.py b/tasklib/tests.py index 686e086..3a3f25d 100644 --- a/tasklib/tests.py +++ b/tasklib/tests.py @@ -595,7 +595,7 @@ class AnnotationTest(TasklibTest): t.add_annotation("annotation1") t.add_annotation("annotation2") - data = json.loads(t._serialize('annotations', t._data['annotations'])) + data = t._serialize('annotations', t._data['annotations']) self.assertEqual(len(data), 2) self.assertEqual(type(data[0]), dict) -- 2.39.5