changeset 1355:6f342b36871c

pages (g): set `interests_map` even in case of errors
author Goffi <goffi@goffi.org>
date Thu, 17 Sep 2020 08:59:43 +0200
parents 4751e9febbbf
children 39719ff4fcad
files libervia/pages/g/page_meta.py
diffstat 1 files changed, 6 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libervia/pages/g/page_meta.py	Sun Sep 13 15:01:24 2020 +0200
+++ b/libervia/pages/g/page_meta.py	Thu Sep 17 08:59:43 2020 +0200
@@ -3,7 +3,6 @@
 
 from libervia.server.constants import Const as C
 from sat.core.i18n import _
-from twisted.internet import defer
 from libervia.server import session_iface
 from sat.core.log import getLogger
 
@@ -13,8 +12,7 @@
 template = "invitation/welcome.html"
 
 
-@defer.inlineCallbacks
-def parse_url(self, request):
+async def parse_url(self, request):
     """check invitation id in URL and start session if needed
 
     if a session already exists for an other guest/profile, it will be purged
@@ -58,7 +56,7 @@
     if current_id is None:
         log.debug(_("checking invitation [{id}]").format(id=invitation_id))
         try:
-            data = yield self.host.bridgeCall("invitationGet", invitation_id)
+            data = await self.host.bridgeCall("invitationGet", invitation_id)
         except Exception:
             self.pageError(request, C.HTTP_FORBIDDEN)
         else:
@@ -73,7 +71,7 @@
         profile = data["guest_profile"]
         password = data["password"]
         try:
-            yield self.host.connect(request, profile, password)
+            await self.host.connect(request, profile, password)
         except Exception as e:
             log.warning(_("Can't connect profile: {msg}").format(msg=e))
             # FIXME: no good error code correspond
@@ -127,14 +125,14 @@
     interest["url"] = self.getPageByName(page_name).getURL(
         interest['service'], *path_args)
 
-@defer.inlineCallbacks
-def prepare_render(self, request):
+async def prepare_render(self, request):
     template_data = request.template_data
     profile = self.getProfile(request)
 
     # interests
+    template_data['interests_map'] = interests_map = {}
     try:
-        interests = yield self.host.bridgeCall(
+        interests = await self.host.bridgeCall(
             "interestsList", "", "", "", profile)
     except Exception:
         log.warning(_("Can't get interests list for {profile}").format(
@@ -144,7 +142,6 @@
         # this dict map namespaces of interest to a callback which can manipulate
         # the data. If it returns False, the interest is skipped
         ns_data = {}
-        template_data['interests_map'] = interests_map = {}
 
         for short_name, cb in (('event', handleEventInterest),
                                ('fis', handleFISInterest),