diff sat/tools/common/data_objects.py @ 2807:0b7ce5daee9b

plugin XEP-0277: blog items data are now entirely serialised before going to bridge: So far, and for historical reasons, blog items data where serialised using a unicode: unicode dict, which was causing trouble for many types of values (timestamps, booleans, lists). This patch changes it by serialising the whole items before going to bridge, and deserialising it when going back. This way, complex data can be used easily in items. This impact psEvent and serItemsData* methods which are renamed transItemsData* because there are not always serialising anymore (a new argument "serialise" allows to specify it). When editing a blog post in jp, metadata are now more easy to manipulate, specially lists like tags.
author Goffi <goffi@goffi.org>
date Sat, 23 Feb 2019 18:59:00 +0100
parents 003b8b4b56a7
children 8dbef2d190eb
line wrap: on
line diff
--- a/sat/tools/common/data_objects.py	Wed Feb 20 19:42:35 2019 +0100
+++ b/sat/tools/common/data_objects.py	Sat Feb 23 18:59:00 2019 +0100
@@ -73,10 +73,8 @@
 
 class BlogItem(object):
     def __init__(self, mb_data, parent):
-        self.mb_data = mb_data
+        self.mb_data = data_format.deserialise(mb_data)
         self.parent = parent
-        self._tags = None
-        self._groups = None
         self._comments = None
         self._comments_items_list = None
 
@@ -126,15 +124,11 @@
 
     @property
     def tags(self):
-        if self._tags is None:
-            self._tags = list(data_format.dict2iter("tag", self.mb_data))
-        return self._tags
+        return self.mb_data.get(u'tags', [])
 
     @property
     def groups(self):
-        if self._groups is None:
-            self._groups = list(data_format.dict2iter("group", self.mb_data))
-        return self._groups
+        return self.mb_data.get(u'groups', [])
 
     @property
     def title(self):