changeset 1421:e065c8886b81

pages (files/list): set empty affiliations when they can't be retrieved
author Goffi <goffi@goffi.org>
date Sat, 01 May 2021 19:04:25 +0200
parents 925a7c498cda
children 027f5059e1e2
files libervia/pages/files/list/page_meta.py libervia/pages/files/page_meta.py libervia/pages/files/view/page_meta.py
diffstat 3 files changed, 7 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libervia/pages/files/list/page_meta.py	Sat May 01 18:50:04 2021 +0200
+++ b/libervia/pages/files/list/page_meta.py	Sat May 01 19:04:25 2021 +0200
@@ -125,6 +125,8 @@
             affiliations = {
                 session_data.jid.userhost(): "owner"
             }
+        if e.condition == "service-unavailable":
+            affiliations = {}
         else:
             raise e
 
--- a/libervia/pages/files/page_meta.py	Sat May 01 18:50:04 2021 +0200
+++ b/libervia/pages/files/page_meta.py	Sat May 01 19:04:25 2021 +0200
@@ -2,7 +2,6 @@
 
 
 from libervia.server.constants import Const as C
-from twisted.internet import defer
 from twisted.words.protocols.jabber import jid
 from sat.core.log import getLogger
 
@@ -14,12 +13,11 @@
 template = "file/discover.html"
 
 
-@defer.inlineCallbacks
-def prepare_render(self, request):
+async def prepare_render(self, request):
     profile = self.getProfile(request)
     template_data = request.template_data
     namespace = self.host.ns_map["fis"]
-    entities_services, entities_own, entities_roster = yield self.host.bridgeCall(
+    entities_services, entities_own, entities_roster = await self.host.bridgeCall(
         "discoFindByFeatures", [namespace], [], False, True, True, True, False, profile
     )
     tpl_service_entities = template_data["disco_service_entities"] = {}
--- a/libervia/pages/files/view/page_meta.py	Sat May 01 18:50:04 2021 +0200
+++ b/libervia/pages/files/view/page_meta.py	Sat May 01 19:04:25 2021 +0200
@@ -3,7 +3,6 @@
 
 from libervia.server.constants import Const as C
 from sat.core.i18n import _
-from twisted.internet import defer
 from twisted.web import static
 from libervia.server.utils import ProgressHandler
 import tempfile
@@ -33,8 +32,7 @@
         log.warning(_("Can't remove temporary directory {path}").format(path=tmp_dir))
 
 
-@defer.inlineCallbacks
-def render(self, request):
+async def render(self, request):
     data = self.getRData(request)
     profile = self.getProfile(request)
     service, path_elts = data["service"], data["path"]
@@ -44,7 +42,7 @@
     tmp_dir = tempfile.mkdtemp()
     dest_path = os.path.join(tmp_dir, basename)
     request.notifyFinish().addCallback(cleanup, tmp_dir, dest_path)
-    progress_id = yield self.host.bridgeCall(
+    progress_id = await self.host.bridgeCall(
         "fileJingleRequest",
         service.full(),
         dest_path,
@@ -55,6 +53,6 @@
         profile,
     )
     log.debug("file requested")
-    yield ProgressHandler(self.host, progress_id, profile).register()
+    await ProgressHandler(self.host, progress_id, profile).register()
     log.debug("file downloaded")
     self.delegateToResource(request, static.File(dest_path))