changeset 1302:04e7dd6b6f4d

pages (blog, tickets, merge-requests): updated code to handle new serialisation, following backend changes
author Goffi <goffi@goffi.org>
date Thu, 16 Jul 2020 09:08:47 +0200
parents ff44f822bfdd
children a48fe20f60c7
files libervia/pages/blog/view/page_meta.py libervia/pages/events/admin/page_meta.py libervia/pages/merge-requests/edit/page_meta.py libervia/pages/merge-requests/page_meta.py libervia/pages/merge-requests/view/page_meta.py libervia/pages/tickets/edit/page_meta.py libervia/pages/tickets/new/page_meta.py libervia/pages/tickets/page_meta.py libervia/pages/tickets/view/page_meta.py libervia/server/pages.py libervia/server/pages_tools.py
diffstat 11 files changed, 125 insertions(+), 117 deletions(-) [+]
line wrap: on
line diff
--- a/libervia/pages/blog/view/page_meta.py	Fri Jun 19 16:47:51 2020 +0200
+++ b/libervia/pages/blog/view/page_meta.py	Thu Jul 16 09:08:47 2020 +0200
@@ -111,17 +111,18 @@
 
 @defer.inlineCallbacks
 def appendComments(self, blog_items, identities, profile):
-    for blog_item in blog_items:
+    for blog_item in blog_items['items']:
         if identities is not None:
-            author = blog_item.author_jid
+            author = blog_item['author_jid']
             if not author:
-                log.warning(_("no author found for item {item_id}").format(item_id=blog_item.id))
+                log.warning(_("no author found for item {item_id}").format(
+                    item_id=blog_item['id']))
             else:
                 if author not in identities:
                     id_raw = yield self.host.bridgeCall(
                         'identityGet', author, [], True, profile)
                     identities[author] = data_format.deserialise(id_raw)
-        for comment_data in blog_item.comments:
+        for comment_data in blog_item['comments']:
             service = comment_data['service']
             node = comment_data['node']
             try:
@@ -133,14 +134,15 @@
                                       {C.KEY_ORDER_BY: C.ORDER_BY_CREATION},
                                       profile)
             except Exception as e:
-                log.warning(_("Can't get comments at {node} (service: {service}): {msg}").format(
-                    service=service,
-                    node=node,
-                    msg=e))
+                log.warning(
+                    _("Can't get comments at {node} (service: {service}): {msg}").format(
+                        service=service,
+                        node=node,
+                        msg=e))
                 continue
 
-            comments = data_objects.BlogItems(comments_data)
-            blog_item.appendCommentsItems(comments)
+            comments = data_format.deserialise(comments_data)
+            comment_data['items'] = comments['items']
             yield appendComments(self, comments, identities, profile)
 
 @defer.inlineCallbacks
@@ -164,9 +166,11 @@
         else:
             log.warning(_("can't retrieve blog for [{service}]: {msg}".format(
                 service = service.userhost(), msg=e)))
-            blog_data = ([], {})
+            blog_data = {"items": []}
+    else:
+        blog_data = data_format.deserialise(blog_data)
 
-    defer.returnValue(data_objects.BlogItems(blog_data))
+    defer.returnValue(blog_data)
 
 @defer.inlineCallbacks
 def prepare_render(self, request):
@@ -192,7 +196,7 @@
 
     ## main data ##
     # we get data from backend/XMPP here
-    items = yield getBlogItems(self, request, service, node, item_id, extra, profile)
+    blog_items = yield getBlogItems(self, request, service, node, item_id, extra, profile)
 
     ## navigation ##
     # no let's fill service, node and pagination URLs
@@ -203,9 +207,9 @@
         template_data['node'] = node
     target_profile = template_data.get('target_profile')
 
-    if items:
+    if blog_items:
         if not item_id:
-            self.setPagination(request, items.metadata)
+            self.setPagination(request, blog_items)
     else:
         if item_id:
             # if item id has been specified in URL and it's not found,
@@ -219,7 +223,7 @@
     ## Comments ##
     # if comments are requested, we need to take them
     if show_comments:
-        yield appendComments(self, items, identities, profile)
+        yield appendComments(self, blog_items, identities, profile)
 
     ## URLs ##
     # We will fill items_http_uri and tags_http_uri in template_data with suitable urls
@@ -239,21 +243,21 @@
                 }
                 """ % html.escape(bg_img, True))
 
-    template_data['items'] = data['items'] = items
+    template_data['blog_items'] = data['blog_items'] = blog_items
     if request.args.get(b'reverse') == ['1']:
-        template_data['items'].items.reverse()
+        template_data['blog_items'].items.reverse()
     template_data['items_http_uri'] = items_http_uri = {}
     template_data['tags_http_uri'] = tags_http_uri = {}
 
 
-    for item in items:
-        blog_canonical_url = '/'.join([blog_base_url_item, utils.quote(item.id)])
+    for item in blog_items['items']:
+        blog_canonical_url = '/'.join([blog_base_url_item, utils.quote(item['id'])])
         if len(blog_canonical_url) > URL_LIMIT_MARK:
             blog_url = blog_canonical_url
         else:
             # we add text from title or body at the end of URL
             # to make it more human readable
-            text = item.title or item.content
+            text = item.get('title', item['content'])
             # we change special chars to ascii one, trick found at https://stackoverflow.com/a/3194567
             text = unicodedata.normalize('NFD', text).encode('ascii', 'ignore').decode('utf-8')
             text = RE_TEXT_URL.sub(' ', text).lower()
@@ -268,8 +272,8 @@
             else:
                 blog_url = blog_canonical_url
 
-        items_http_uri[item.id] = self.host.getExtBaseURL(request, blog_url)
-        for tag in item.tags:
+        items_http_uri[item['id']] = self.host.getExtBaseURL(request, blog_url)
+        for tag in item['tags']:
             if tag not in tags_http_uri:
                 tag_url = '/'.join([blog_base_url_tag, utils.quote(tag)])
                 tags_http_uri[tag] = self.host.getExtBaseURL(request, tag_url)
--- a/libervia/pages/events/admin/page_meta.py	Fri Jun 19 16:47:51 2020 +0200
+++ b/libervia/pages/events/admin/page_meta.py	Thu Jul 16 09:08:47 2020 +0200
@@ -5,6 +5,7 @@
 from twisted.internet import defer
 from twisted.words.protocols.jabber import jid
 from sat.tools.common.template import safe
+from sat.tools.common import data_format
 from sat.core.i18n import _
 from sat.core.log import getLogger
 import time
@@ -29,8 +30,7 @@
     )
 
 
-@defer.inlineCallbacks
-def prepare_render(self, request):
+async def prepare_render(self, request):
     data = self.getRData(request)
     template_data = request.template_data
 
@@ -40,7 +40,7 @@
     event_node = template_data["event_node"] = data["event_node"]
     event_id = template_data["event_id"] = data["event_id"]
     profile = self.getProfile(request)
-    event_timestamp, event_data = yield self.host.bridgeCall(
+    event_timestamp, event_data = await self.host.bridgeCall(
         "eventGet",
         event_service.userhost() if event_service else "",
         event_node,
@@ -62,7 +62,7 @@
             % html.escape(background_image, True)
         )
     template_data["event"] = event_data
-    invitees = yield self.host.bridgeCall(
+    invitees = await self.host.bridgeCall(
         "eventInviteesList",
         event_data["invitees_service"],
         event_data["invitees_node"],
@@ -93,11 +93,10 @@
     # we now need blog items, using blog common page
     # this will fill the "items" template data
     blog_page = self.getPageByName("blog_view")
-    yield blog_page.prepare_render(self, request)
+    await blog_page.prepare_render(self, request)
 
 
-@defer.inlineCallbacks
-def on_data_post(self, request):
+async def on_data_post(self, request):
     profile = self.getProfile(request)
     if not profile:
         log.error("got post data without profile")
@@ -121,10 +120,11 @@
             pass
         else:
             if comments:
-                data["allow_comments"] = C.BOOL_TRUE
+                data["allow_comments"] = True
 
         try:
-            yield self.host.bridgeCall("mbSend", service, node, data, profile)
+            await self.host.bridgeCall(
+                "mbSend", service, node, data_format.serialise(data), profile)
         except Exception as e:
             if "forbidden" in str(e):
                 self.pageError(request, C.HTTP_FORBIDDEN)
@@ -142,7 +142,7 @@
                     _("this is not a valid jid: {jid}").format(jid=invitee_jid_s)
                 )
                 continue
-            yield self.host.bridgeCall(
+            await self.host.bridgeCall(
                 "eventInvite", invitee_jid.userhost(), service, node, event_id, profile
             )
         for email_addr in emails.split():
@@ -153,7 +153,7 @@
                     )
                 )
                 continue
-            yield self.host.bridgeCall(
+            await self.host.bridgeCall(
                 "eventInviteByEmail",
                 service,
                 node,
--- a/libervia/pages/merge-requests/edit/page_meta.py	Fri Jun 19 16:47:51 2020 +0200
+++ b/libervia/pages/merge-requests/edit/page_meta.py	Thu Jul 16 09:08:47 2020 +0200
@@ -27,8 +27,7 @@
     data["ticket_id"] = item_id
 
 
-@defer.inlineCallbacks
-def prepare_render(self, request):
+async def prepare_render(self, request):
     data = self.getRData(request)
     template_data = request.template_data
     service, node, ticket_id = (
@@ -49,17 +48,19 @@
         "request_data",
         "type",
     )
-    tickets = yield self.host.bridgeCall(
-        "mergeRequestsGet",
-        service.full() if service else "",
-        node,
-        C.NO_LIMIT,
-        [ticket_id],
-        "",
-        {},
-        profile,
+    merge_requests = data_format.deserialise(
+        await self.host.bridgeCall(
+            "mergeRequestsGet",
+            service.full() if service else "",
+            node,
+            C.NO_LIMIT,
+            [ticket_id],
+            "",
+            {},
+            profile,
+        )
     )
-    ticket = [template_xmlui.create(self.host, x, ignore=ignore) for x in tickets[0]][0]
+    ticket = template_xmlui.create(self.host, merge_requests['items'][0], ignore=ignore)
 
     try:
         # small trick to get a one line text input instead of the big textarea
@@ -74,15 +75,14 @@
     wid = ticket.widgets['body']
     if wid.type == "xhtmlbox":
         wid.type = "textbox"
-        wid.value =  yield self.host.bridgeCall(
+        wid.value =  await self.host.bridgeCall(
             "syntaxConvert", wid.value, C.SYNTAX_XHTML, "markdown",
             False, profile)
 
     template_data["new_ticket_xmlui"] = ticket
 
 
-@defer.inlineCallbacks
-def on_data_post(self, request):
+async def on_data_post(self, request):
     data = self.getRData(request)
     service = data["service"]
     node = data["node"]
@@ -97,14 +97,14 @@
     profile = self.getProfile(request)
 
     # we convert back body to XHTML
-    body = yield self.host.bridgeCall(
+    body = await self.host.bridgeCall(
         "syntaxConvert", posted_data['body'][0], "markdown", C.SYNTAX_XHTML,
         False, profile)
     posted_data['body'] = ['<div xmlns="{ns}">{body}</div>'.format(ns=C.NS_XHTML,
                                                                      body=body)]
 
     extra = {'update': True}
-    yield self.host.bridgeCall(
+    await self.host.bridgeCall(
         "mergeRequestSet",
         service.full(),
         node,
--- a/libervia/pages/merge-requests/page_meta.py	Fri Jun 19 16:47:51 2020 +0200
+++ b/libervia/pages/merge-requests/page_meta.py	Thu Jul 16 09:08:47 2020 +0200
@@ -4,6 +4,7 @@
 from libervia.server.constants import Const as C
 from twisted.internet import defer
 from sat.tools.common import template_xmlui
+from sat.tools.common import data_format
 from sat.tools.common import data_objects
 from sat.core.log import getLogger
 
@@ -33,25 +34,27 @@
     template_data["url_tickets_new"] = self.getSubPageURL(request, "merge-requests_new")
 
 
-@defer.inlineCallbacks
-def prepare_render(self, request):
+async def prepare_render(self, request):
     data = self.getRData(request)
     template_data = request.template_data
     service, node = data["service"], data["node"]
     profile = self.getProfile(request) or C.SERVICE_PROFILE
 
-    merge_requests = yield self.host.bridgeCall(
-        "mergeRequestsGet",
-        service.full() if service else "",
-        node,
-        C.NO_LIMIT,
-        [],
-        "",
-        {"labels_as_list": C.BOOL_TRUE},
-        profile,
+    merge_requests = data_format.deserialise(
+        await self.host.bridgeCall(
+            "mergeRequestsGet",
+            service.full() if service else "",
+            node,
+            C.NO_LIMIT,
+            [],
+            "",
+            {"labels_as_list": C.BOOL_TRUE},
+            profile,
+        )
     )
+
     template_data["tickets"] = [
-        template_xmlui.create(self.host, x) for x in merge_requests[0]
+        template_xmlui.create(self.host, x) for x in merge_requests['items']
     ]
     template_data["on_ticket_click"] = data_objects.OnClick(
         url=self.getSubPageURL(request, "merge-requests_view") + "/{item.id}"
--- a/libervia/pages/merge-requests/view/page_meta.py	Fri Jun 19 16:47:51 2020 +0200
+++ b/libervia/pages/merge-requests/view/page_meta.py	Thu Jul 16 09:08:47 2020 +0200
@@ -9,7 +9,7 @@
 from twisted.words.protocols.jabber import jid
 from sat.tools.common import template_xmlui
 from sat.tools.common import uri
-from sat.tools.common import data_objects
+from sat.tools.common import data_format
 from sat.core.log import getLogger
 
 name = "merge-requests_view"
@@ -29,8 +29,7 @@
     data["ticket_id"] = item_id
 
 
-@defer.inlineCallbacks
-def prepare_render(self, request):
+async def prepare_render(self, request):
     data = self.getRData(request)
     template_data = request.template_data
     session = self.host.getSessionData(request, session_iface.ISATSession)
@@ -44,29 +43,32 @@
     if profile is None:
         profile = C.SERVICE_PROFILE
 
-    tickets, metadata, parsed_tickets = yield self.host.bridgeCall(
-        "mergeRequestsGet",
-        service.full() if service else "",
-        node,
-        C.NO_LIMIT,
-        [ticket_id],
-        "",
-        {"parse": C.BOOL_TRUE, "labels_as_list": C.BOOL_TRUE},
-        profile,
+    merge_requests = data_format.deserialise(
+        await self.host.bridgeCall(
+            "mergeRequestsGet",
+            service.full() if service else "",
+            node,
+            C.NO_LIMIT,
+            [ticket_id],
+            "",
+            {"parse": C.BOOL_TRUE, "labels_as_list": C.BOOL_TRUE},
+            profile,
+        )
     )
-    ticket = template_xmlui.create(self.host, tickets[0], ignore=["request_data", "type"])
+    ticket = template_xmlui.create(
+        self.host, merge_requests['items'][0], ignore=["request_data", "type"]
+    )
     template_data["item"] = ticket
-    template_data["patches"] = parsed_tickets[0]
+    template_data["patches"] = merge_requests['items_patches'][0]
     comments_uri = ticket.widgets["comments_uri"].value
     if comments_uri:
         uri_data = uri.parseXMPPUri(comments_uri)
         template_data["comments_node"] = comments_node = uri_data["node"]
         template_data["comments_service"] = comments_service = uri_data["path"]
-        comments = yield self.host.bridgeCall(
+        template_data["comments"] = data_format.deserialise(await self.host.bridgeCall(
             "mbGet", comments_service, comments_node, C.NO_LIMIT, [], {}, profile
-        )
+        ))
 
-        template_data["comments"] = data_objects.BlogItems(comments)
         template_data["login_url"] = self.getPageRedirectURL(request)
 
     if session.connected:
@@ -76,7 +78,7 @@
         affiliation = None
         if not is_publisher:
             node = node or self.host.ns_map["merge_requests"]
-            affiliation = yield self.host.getAffiliation(request, service, node)
+            affiliation = await self.host.getAffiliation(request, service, node)
         if is_publisher or affiliation == "owner":
             template_data["url_ticket_edit"] = self.getURLByPath(
                 SubPage("merge-requests"),
@@ -87,11 +89,10 @@
             )
 
 
-@defer.inlineCallbacks
-def on_data_post(self, request):
+async def on_data_post(self, request):
     type_ = self.getPostedData(request, "type")
     if type_ == "comment":
         blog_page = self.getPageByName("blog_view")
-        yield blog_page.on_data_post(self, request)
+        await blog_page.on_data_post(self, request)
     else:
         log.warning(_("Unhandled data type: {}").format(type_))
--- a/libervia/pages/tickets/edit/page_meta.py	Fri Jun 19 16:47:51 2020 +0200
+++ b/libervia/pages/tickets/edit/page_meta.py	Thu Jul 16 09:08:47 2020 +0200
@@ -49,7 +49,7 @@
         "updated",
         "comments_uri",
     )
-    tickets = yield self.host.bridgeCall(
+    tickets_raw = yield self.host.bridgeCall(
         "ticketsGet",
         service.full() if service else "",
         node,
@@ -59,7 +59,8 @@
         {},
         profile,
     )
-    ticket = [template_xmlui.create(self.host, x, ignore=ignore) for x in tickets[0]][0]
+    tickets, metadata = data_format.deserialise(tickets_raw, type_check=list)
+    ticket = [template_xmlui.create(self.host, x, ignore=ignore) for x in tickets][0]
 
     try:
         # small trick to get a one line text input instead of the big textarea
--- a/libervia/pages/tickets/new/page_meta.py	Fri Jun 19 16:47:51 2020 +0200
+++ b/libervia/pages/tickets/new/page_meta.py	Thu Jul 16 09:08:47 2020 +0200
@@ -1,6 +1,5 @@
 #!/usr/bin/env python3
 
-
 from libervia.server.constants import Const as C
 from twisted.internet import defer
 from sat.tools.common import template_xmlui
@@ -14,13 +13,12 @@
 template = "ticket/create.html"
 
 
-@defer.inlineCallbacks
-def prepare_render(self, request):
+async def prepare_render(self, request):
     data = self.getRData(request)
     template_data = request.template_data
     service, node = data.get("service", ""), data.get("node", "")
     profile = self.getProfile(request)
-    schema = yield self.host.bridgeCall("ticketsSchemaGet", service.full(), node, profile)
+    schema = await self.host.bridgeCall("ticketsSchemaGet", service.full(), node, profile)
     data["schema"] = schema
     # following fields are handled in backend
     ignore = (
@@ -45,14 +43,13 @@
     wid = xmlui_obj.widgets['body']
     if wid.type == "xhtmlbox":
         wid.type = "textbox"
-        wid.value =  yield self.host.bridgeCall(
+        wid.value =  await self.host.bridgeCall(
             "syntaxConvert", wid.value, C.SYNTAX_XHTML, "markdown",
             False, profile)
     template_data["new_ticket_xmlui"] = xmlui_obj
 
 
-@defer.inlineCallbacks
-def on_data_post(self, request):
+async def on_data_post(self, request):
     data = self.getRData(request)
     service = data["service"]
     node = data["node"]
@@ -66,14 +63,14 @@
     profile = self.getProfile(request)
 
     # we convert back body to XHTML
-    body = yield self.host.bridgeCall(
+    body = await self.host.bridgeCall(
         "syntaxConvert", posted_data['body'][0], "markdown", C.SYNTAX_XHTML,
         False, profile)
     posted_data['body'] = ['<div xmlns="{ns}">{body}</div>'.format(ns=C.NS_XHTML,
                                                                      body=body)]
 
 
-    yield self.host.bridgeCall(
+    await self.host.bridgeCall(
         "ticketSet", service.full(), node, posted_data, "", "", "", profile
     )
     # we don't want to redirect to creation page on success, but to tickets list
--- a/libervia/pages/tickets/page_meta.py	Fri Jun 19 16:47:51 2020 +0200
+++ b/libervia/pages/tickets/page_meta.py	Thu Jul 16 09:08:47 2020 +0200
@@ -5,6 +5,7 @@
 from twisted.internet import defer
 from sat.tools.common import template_xmlui
 from sat.tools.common import data_objects
+from sat.tools.common import data_format
 from sat.core.log import getLogger
 
 log = getLogger(__name__)
@@ -28,8 +29,7 @@
     template_data["url_tickets_new"] = self.getSubPageURL(request, "tickets_new")
 
 
-@defer.inlineCallbacks
-def prepare_render(self, request):
+async def prepare_render(self, request):
     data = self.getRData(request)
     template_data = request.template_data
     service, node = data["service"], data["node"]
@@ -40,7 +40,7 @@
     extra = self.getPubsubExtra(request)
     extra["labels_as_list"] = C.BOOL_TRUE
 
-    tickets, metadata = yield self.host.bridgeCall(
+    tickets_data_raw = await self.host.bridgeCall(
         "ticketsGet",
         service.full() if service else "",
         node,
@@ -50,9 +50,9 @@
         extra,
         profile,
     )
+    tickets, metadata = data_format.deserialise(tickets_data_raw, type_check=list)
     template_data["tickets"] = [template_xmlui.create(self.host, x) for x in tickets]
     template_data["on_ticket_click"] = data_objects.OnClick(
         url=self.getSubPageURL(request, "tickets_view") + "/{item.id}"
     )
-    metadata = data_objects.parsePubSubMetadata(metadata, tickets)
     self.setPagination(request, metadata)
--- a/libervia/pages/tickets/view/page_meta.py	Fri Jun 19 16:47:51 2020 +0200
+++ b/libervia/pages/tickets/view/page_meta.py	Thu Jul 16 09:08:47 2020 +0200
@@ -9,7 +9,7 @@
 from twisted.words.protocols.jabber import jid
 from sat.tools.common import template_xmlui
 from sat.tools.common import uri
-from sat.tools.common import data_objects
+from sat.tools.common import data_format
 from sat.core.log import getLogger
 
 log = getLogger(__name__)
@@ -31,8 +31,7 @@
     data["ticket_id"] = item_id
 
 
-@defer.inlineCallbacks
-def prepare_render(self, request):
+async def prepare_render(self, request):
     data = self.getRData(request)
     template_data = request.template_data
     session = self.host.getSessionData(request, session_iface.ISATSession)
@@ -46,7 +45,7 @@
     if profile is None:
         profile = C.SERVICE_PROFILE
 
-    tickets = yield self.host.bridgeCall(
+    tickets_raw = await self.host.bridgeCall(
         "ticketsGet",
         service.full() if service else "",
         node,
@@ -56,18 +55,19 @@
         {"labels_as_list": C.BOOL_TRUE},
         profile,
     )
-    ticket = [template_xmlui.create(self.host, x) for x in tickets[0]][0]
+    tickets, metadata = data_format.deserialise(tickets_raw, type_check=list)
+    ticket = [template_xmlui.create(self.host, x) for x in tickets][0]
     template_data["item"] = ticket
     comments_uri = ticket.widgets["comments_uri"].value
     if comments_uri:
         uri_data = uri.parseXMPPUri(comments_uri)
         template_data["comments_node"] = comments_node = uri_data["node"]
         template_data["comments_service"] = comments_service = uri_data["path"]
-        comments = yield self.host.bridgeCall(
+        comments = data_format.deserialise(await self.host.bridgeCall(
             "mbGet", comments_service, comments_node, C.NO_LIMIT, [], {}, profile
-        )
+        ))
 
-        template_data["comments"] = data_objects.BlogItems(comments)
+        template_data["comments"] = comments
         template_data["login_url"] = self.getPageRedirectURL(request)
 
     if session.connected:
@@ -77,7 +77,7 @@
         affiliation = None
         if not is_publisher:
             node = node or self.host.ns_map["tickets"]
-            affiliation = yield self.host.getAffiliation(request, service, node)
+            affiliation = await self.host.getAffiliation(request, service, node)
         if is_publisher or affiliation == "owner":
             template_data["url_ticket_edit"] = self.getURLByPath(
                 SubPage("tickets"),
--- a/libervia/server/pages.py	Fri Jun 19 16:47:51 2020 +0200
+++ b/libervia/server/pages.py	Thu Jul 16 09:08:47 2020 +0200
@@ -954,16 +954,17 @@
         """
         template_data = request.template_data
         try:
-            last_id = pubsub_data["rsm_last"]
+            rsm = pubsub_data["rsm"]
+            last_id = rsm["last"]
         except KeyError:
             # no pagination available
             return
 
-        if pubsub_data.get("rsm_index", 1) > 0:
+        if rsm.get("index", 1) > 0:
             # We only show previous button if it's not the first page already.
             # If we have no index, we default to display the button anyway
             # as we can't know if we are on the first page or not.
-            first_id = pubsub_data["rsm_first"]
+            first_id = rsm["first"]
             template_data['previous_page_url'] = self.getParamURL(request,
                                                                   before=first_id)
         if not pubsub_data["complete"]:
--- a/libervia/server/pages_tools.py	Fri Jun 19 16:47:51 2020 +0200
+++ b/libervia/server/pages_tools.py	Thu Jul 16 09:08:47 2020 +0200
@@ -19,17 +19,18 @@
 
 """Helper methods for common operations on pages"""
 
+from twisted.internet import defer
 from sat.core.i18n import _
+from sat.core.log import getLogger
+from sat.tools.common import data_format
 from libervia.server.constants import Const as C
-from twisted.internet import defer
-from sat.core.log import getLogger
+
 
 log = getLogger(__name__)
-from sat.tools.common import data_objects
 
 
-def commentsDataToObjects(comments_data):
-    return data_objects.BlogItems(comments_data)
+def deserialise(comments_data_s):
+    return data_format.deserialise(comments_data_s)
 
 
 def retrieveComments(self, service, node, profile, pass_exceptions=True):
@@ -54,5 +55,5 @@
             )
             return defer.succeed([])
 
-    d.addCallback(commentsDataToObjects)
+    d.addCallback(deserialise)
     return d