Mercurial > libervia-backend
changeset 2942:8dbef2d190eb
tools (common/data_objects): added a "deserialise" argument to BlogItem:
BlogItem is doing deserialisation itself, which is not clean (it should be done at bridge level), and which is causing trouble in jp which doesn't expect serialisation.
As a workaround, the "deserialise" argument has been added for now (default to True), until deserialisation is properly managed in bridge.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 05 May 2019 18:50:30 +0200 |
parents | 83cbd4545274 |
children | 781b5b6a33ee |
files | sat/tools/common/data_objects.py |
diffstat | 1 files changed, 17 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/sat/tools/common/data_objects.py Sat May 04 00:06:41 2019 +0200 +++ b/sat/tools/common/data_objects.py Sun May 05 18:50:30 2019 +0200 @@ -72,8 +72,16 @@ class BlogItem(object): - def __init__(self, mb_data, parent): - self.mb_data = data_format.deserialise(mb_data) + def __init__(self, mb_data, parent, deserialise=True): + """ + @param deserialise(bool): if True, mb_data is a serialised string which must + be deserialised + """ + # FIXME: deserialise should not be done here, but before BlogItem is called + if deserialise: + self.mb_data = data_format.deserialise(mb_data) + else: + self.mb_data = mb_data self.parent = parent self._comments = None self._comments_items_list = None @@ -180,8 +188,13 @@ class BlogItems(object): - def __init__(self, mb_data): - self.items = [BlogItem(i, self) for i in mb_data[0]] + def __init__(self, mb_data, deserialise=True): + """ + @param deserialise(bool): if True, mb_data is a serialised string which must + be deserialised + """ + # FIXME: deserialise should not be done here, but before BlogItem is called + self.items = [BlogItem(i, self, deserialise=deserialise) for i in mb_data[0]] self.metadata = parsePubSubMetadata(mb_data[1], self.items) @property