changeset 1098:01e95ec9df9e

server, pages: fixed blocking calls to bridge by using bridgeCall instead
author Goffi <goffi@goffi.org>
date Fri, 01 Jun 2018 15:09:19 +0200
parents f134c0ecb1d5
children ea0d41ef3719
files src/pages/g/page_meta.py src/pages/merge-requests/edit/page_meta.py src/pages/merge-requests/page_meta.py src/pages/merge-requests/view/page_meta.py src/pages/tickets/edit/page_meta.py src/pages/tickets/new/page_meta.py src/pages/tickets/view/page_meta.py src/pages/u/page_meta.py src/server/server.py
diffstat 9 files changed, 42 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/src/pages/g/page_meta.py	Fri Jun 01 15:07:06 2018 +0200
+++ b/src/pages/g/page_meta.py	Fri Jun 01 15:09:19 2018 +0200
@@ -46,7 +46,7 @@
     if current_id is None:
         log.debug(_(u"checking invitation [{id}]").format(id=invitation_id))
         try:
-            data = yield self.host.bridge.invitationGet(invitation_id)
+            data = yield self.host.bridgeCall("invitationGet", invitation_id)
         except Exception:
             self.pageError(request, C.HTTP_UNAUTHORIZED)
         else:
@@ -61,7 +61,7 @@
         profile = data['guest_profile']
         password = data['password']
         try:
-            yield self.host.bridge.connect(profile, password, {})
+            yield self.host.bridgeCall("connect", profile, password, {})
         except Exception as e:
             log.warning(_(u"Can't connect profile: {msg}").format(
                 msg=e))
--- a/src/pages/merge-requests/edit/page_meta.py	Fri Jun 01 15:07:06 2018 +0200
+++ b/src/pages/merge-requests/edit/page_meta.py	Fri Jun 01 15:09:19 2018 +0200
@@ -33,7 +33,7 @@
 
 
     ignore = ('publisher', 'author', 'author_jid', 'author_email', 'created', 'updated', 'comments_uri', 'request_data', 'type')
-    tickets = yield self.host.bridge.mergeRequestsGet(service.full() if service else u'', node, C.NO_LIMIT, [ticket_id], '', {}, profile)
+    tickets = yield self.host.bridgeCall("mergeRequestsGet", service.full() if service else u'', node, C.NO_LIMIT, [ticket_id], '', {}, profile)
     ticket = [template_xmlui.create(self.host, x, ignore=ignore) for x in tickets[0]][0]
 
     try:
@@ -58,15 +58,15 @@
     except (KeyError, IndexError):
         pass
     profile = self.getProfile(request)
-    yield self.host.bridge.mergeRequestSet(service.full(),
-                                            node,
-                                            u'',
-                                            u'auto',
-                                            posted_data,
-                                            u'',
-                                            ticket_id,
-                                            {'update': C.BOOL_TRUE},
-                                            profile)
+    yield self.host.bridgeCall("mergeRequestSet", service.full(),
+                               node,
+                               u'',
+                               u'auto',
+                               posted_data,
+                               u'',
+                               ticket_id,
+                               {'update': C.BOOL_TRUE},
+                               profile)
     # we don't want to redirect to edit page on success, but to tickets list
     data['post_redirect_page'] = (self.getPageByName(u'merge-requests'),
                                   service.full(),
--- a/src/pages/merge-requests/page_meta.py	Fri Jun 01 15:07:06 2018 +0200
+++ b/src/pages/merge-requests/page_meta.py	Fri Jun 01 15:09:19 2018 +0200
@@ -34,6 +34,6 @@
     service, node = data[u'service'], data[u'node']
     profile = self.getProfile(request) or C.SERVICE_PROFILE
 
-    merge_requests = yield self.host.bridge.mergeRequestsGet(service.full() if service else u'', node, C.NO_LIMIT, [], '', {'labels_as_list': C.BOOL_TRUE}, profile)
+    merge_requests = yield self.host.bridgeCall("mergeRequestsGet", service.full() if service else u'', node, C.NO_LIMIT, [], '', {'labels_as_list': C.BOOL_TRUE}, profile)
     template_data[u'tickets'] = [template_xmlui.create(self.host, x) for x in merge_requests[0]]
     template_data[u'on_ticket_click'] = data_objects.OnClick(url=self.getSubPageURL(request, u'merge-requests_view') + u'/{item.id}')
--- a/src/pages/merge-requests/view/page_meta.py	Fri Jun 01 15:07:06 2018 +0200
+++ b/src/pages/merge-requests/view/page_meta.py	Fri Jun 01 15:09:19 2018 +0200
@@ -39,14 +39,14 @@
     if profile is None:
         profile = C.SERVICE_PROFILE
 
-    tickets, metadata, parsed_tickets = yield self.host.bridge.mergeRequestsGet(service.full() if service else u'',
-                                                                                node,
-                                                                                C.NO_LIMIT,
-                                                                                [ticket_id],
-                                                                                '',
-                                                                                {'parse': C.BOOL_TRUE,
-                                                                                 'labels_as_list': C.BOOL_TRUE},
-                                                                                profile)
+    tickets, metadata, parsed_tickets = yield self.host.bridgeCall("mergeRequestsGet", service.full() if service else u'',
+                                                                   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'])
     template_data[u'item'] = ticket
     template_data['patches'] = parsed_tickets[0]
@@ -55,12 +55,13 @@
         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.bridge.mbGet(comments_service,
-                                                comments_node,
-                                                C.NO_LIMIT,
-                                                [],
-                                                {},
-                                                profile)
+        comments = yield self.host.bridgeCall("mbGet",
+                                              comments_service,
+                                              comments_node,
+                                              C.NO_LIMIT,
+                                              [],
+                                              {},
+                                              profile)
 
         template_data[u'comments'] = data_objects.BlogItems(comments)
         template_data[u'login_url'] = self.getPageRedirectURL(request)
--- a/src/pages/tickets/edit/page_meta.py	Fri Jun 01 15:07:06 2018 +0200
+++ b/src/pages/tickets/edit/page_meta.py	Fri Jun 01 15:09:19 2018 +0200
@@ -33,7 +33,7 @@
 
 
     ignore = ('publisher', 'author', 'author_jid', 'author_email', 'created', 'updated', 'comments_uri')
-    tickets = yield self.host.bridge.ticketsGet(service.full() if service else u'', node, C.NO_LIMIT, [ticket_id], '', {}, profile)
+    tickets = yield self.host.bridgeCall("ticketsGet", service.full() if service else u'', node, C.NO_LIMIT, [ticket_id], '', {}, profile)
     ticket = [template_xmlui.create(self.host, x, ignore=ignore) for x in tickets[0]][0]
 
     try:
@@ -58,7 +58,7 @@
     except (KeyError, IndexError):
         pass
     profile = self.getProfile(request)
-    yield self.host.bridge.ticketSet(service.full(), node, posted_data, u'', ticket_id, {}, profile)
+    yield self.host.bridgeCall("ticketSet", service.full(), node, posted_data, u'', ticket_id, {}, profile)
     # we don't want to redirect to edit page on success, but to tickets list
     data['post_redirect_page'] = (self.getPageByName(u'tickets'),
                                   service.full(),
--- a/src/pages/tickets/new/page_meta.py	Fri Jun 01 15:07:06 2018 +0200
+++ b/src/pages/tickets/new/page_meta.py	Fri Jun 01 15:09:19 2018 +0200
@@ -19,7 +19,7 @@
     template_data = request.template_data
     service, node = data.get(u'service', u''), data.get(u'node', u'')
     profile = self.getProfile(request)
-    schema = yield self.host.bridge.ticketsSchemaGet(service.full(), node, profile)
+    schema = yield self.host.bridgeCall("ticketsSchemaGet", service.full(), node, profile)
     data['schema'] = schema
     # following fields are handled in backend
     ignore = ('author', 'author_jid', 'author_email', 'created', 'updated', 'comments_uri', 'status', 'milestone', 'priority')
@@ -44,7 +44,7 @@
     except (KeyError, IndexError):
         pass
     profile = self.getProfile(request)
-    yield self.host.bridge.ticketSet(service.full(), node, posted_data, u'', u'', {}, profile)
+    yield self.host.bridgeCall("ticketSet", service.full(), node, posted_data, u'', u'', {}, profile)
     # we don't want to redirect to creation page on success, but to tickets list
     data['post_redirect_page'] = (self.getPageByName(u'tickets'),
                                   service.full(),
--- a/src/pages/tickets/view/page_meta.py	Fri Jun 01 15:07:06 2018 +0200
+++ b/src/pages/tickets/view/page_meta.py	Fri Jun 01 15:09:19 2018 +0200
@@ -40,7 +40,7 @@
     if profile is None:
         profile = C.SERVICE_PROFILE
 
-    tickets = yield self.host.bridge.ticketsGet(service.full() if service else u'', node, C.NO_LIMIT, [ticket_id], '', {'labels_as_list': C.BOOL_TRUE}, profile)
+    tickets = yield self.host.bridgeCall("ticketsGet", service.full() if service else u'', node, C.NO_LIMIT, [ticket_id], '', {'labels_as_list': C.BOOL_TRUE}, profile)
     ticket = [template_xmlui.create(self.host, x) for x in tickets[0]][0]
     template_data[u'item'] = ticket
     comments_uri = ticket.widgets['comments_uri'].value
@@ -48,12 +48,12 @@
         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.bridge.mbGet(comments_service,
-                                                comments_node,
-                                                C.NO_LIMIT,
-                                                [],
-                                                {},
-                                                profile)
+        comments = yield self.host.bridgeCall("mbGet", comments_service,
+                                              comments_node,
+                                              C.NO_LIMIT,
+                                              [],
+                                              {},
+                                              profile)
 
         template_data[u'comments'] = data_objects.BlogItems(comments)
         template_data[u'login_url'] = self.getPageRedirectURL(request)
--- a/src/pages/u/page_meta.py	Fri Jun 01 15:07:06 2018 +0200
+++ b/src/pages/u/page_meta.py	Fri Jun 01 15:09:19 2018 +0200
@@ -22,9 +22,9 @@
 
     data = self.getRData(request)
 
-    target_profile = yield self.host.bridge.profileNameGet(prof_requested)
+    target_profile = yield self.host.bridgeCall("profileNameGet", prof_requested)
     request.template_data[u'target_profile'] = target_profile
-    target_jid = yield self.host.bridge.asyncGetParamA('JabberID', 'Connection', 'value', profile_key=target_profile)
+    target_jid = yield self.host.bridgeCall("asyncGetParamA", 'JabberID', 'Connection', 'value', profile_key=target_profile)
     target_jid = jid.JID(target_jid)
     data[u'service'] = target_jid
 
--- a/src/server/server.py	Fri Jun 01 15:07:06 2018 +0200
+++ b/src/server/server.py	Fri Jun 01 15:09:19 2018 +0200
@@ -1605,7 +1605,7 @@
             except KeyError:
                 pass
             #and now we disconnect the profile
-            self.bridge.disconnect(profile)
+            self.bridgeCall("disconnect", profile)
 
         session.notifyOnExpire(onExpire)