changeset 2437:91bbad17fd53

plugins blog import, tickets import, XEP-0277: fixed call to getCommentsService (it is now returning a Deferred)
author Goffi <goffi@goffi.org>
date Thu, 16 Nov 2017 07:31:00 +0100
parents b52e78cc86ed
children a34b4fca16e2
files src/plugins/plugin_blog_import.py src/plugins/plugin_tickets_import.py src/plugins/plugin_xep_0277.py
diffstat 3 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/plugin_blog_import.py	Wed Nov 15 21:15:42 2017 +0100
+++ b/src/plugins/plugin_blog_import.py	Thu Nov 16 07:31:00 2017 +0100
@@ -121,24 +121,26 @@
 
         return mb_data
 
+    @defer.inlineCallbacks
     def importSubItems(self, client, item_import_data, mb_data, session, options):
         # comments data
         if len(item_import_data['comments']) != 1:
             raise NotImplementedError(u"can't manage multiple comment links")
         allow_comments = C.bool(mb_data.get('allow_comments', C.BOOL_FALSE))
         if allow_comments:
-            comments_service, comments_node = self._m.getCommentsService(client), self._m.getCommentsNode(mb_data['id'])
+            comments_service = yield self._m.getCommentsService(client)
+            comments_node = self._m.getCommentsNode(mb_data['id'])
             mb_data['comments_service'] = comments_service.full()
             mb_data['comments_node'] = comments_node
             recurse_kwargs = {
                 'items_import_data':item_import_data['comments'][0],
                 'service':comments_service,
                 'node':comments_node}
-            return recurse_kwargs
+            defer.returnValue(recurse_kwargs)
         else:
             if item_import_data['comments'][0]:
                 raise exceptions.DataError(u"allow_comments set to False, but comments are there")
-            return None
+            defer.returnValue(None)
 
     def publishItem(self, client, mb_data, service, node, session):
         log.debug(u"uploading item [{id}]: {title}".format(id=mb_data['id'], title=mb_data.get('title','')))
--- a/src/plugins/plugin_tickets_import.py	Wed Nov 15 21:15:42 2017 +0100
+++ b/src/plugins/plugin_tickets_import.py	Thu Nov 16 07:31:00 2017 +0100
@@ -123,7 +123,8 @@
         # TODO: handle "private" metadata, to have non public access for node
         # TODO: node access/publish model should be customisable
         comments = ticket_data.get('comments', [])
-        service, node = self._m.getCommentsService(client), self._m.getCommentsNode(session['root_node'] + u'_' + ticket_data['id'])
+        service = yield self._m.getCommentsService(client)
+        node = self._m.getCommentsNode(session['root_node'] + u'_' + ticket_data['id'])
         node_options = {self._p.OPT_ACCESS_MODEL: self._p.ACCESS_OPEN,
                         self._p.OPT_PERSIST_ITEMS: 1,
                         self._p.OPT_MAX_ITEMS: -1,
--- a/src/plugins/plugin_xep_0277.py	Wed Nov 15 21:15:42 2017 +0100
+++ b/src/plugins/plugin_xep_0277.py	Thu Nov 16 07:31:00 2017 +0100
@@ -541,7 +541,7 @@
         try:
             comments_service = jid.JID(mb_data['comments_service'])
         except KeyError:
-            comments_service = self.getCommentsService(client, service)
+            comments_service = yield self.getCommentsService(client, service)
 
         try:
             yield self._p.createNode(client, comments_service, comments_node, options)