Mercurial > libervia-backend
comparison src/plugins/plugin_blog_import.py @ 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 | 8b37a62336c3 |
children | 0046283a285d |
comparison
equal
deleted
inserted
replaced
2436:b52e78cc86ed | 2437:91bbad17fd53 |
---|---|
119 log.info(u"url link from {old} to {new}".format( | 119 log.info(u"url link from {old} to {new}".format( |
120 old=old_uri, new=new_uri)) | 120 old=old_uri, new=new_uri)) |
121 | 121 |
122 return mb_data | 122 return mb_data |
123 | 123 |
124 @defer.inlineCallbacks | |
124 def importSubItems(self, client, item_import_data, mb_data, session, options): | 125 def importSubItems(self, client, item_import_data, mb_data, session, options): |
125 # comments data | 126 # comments data |
126 if len(item_import_data['comments']) != 1: | 127 if len(item_import_data['comments']) != 1: |
127 raise NotImplementedError(u"can't manage multiple comment links") | 128 raise NotImplementedError(u"can't manage multiple comment links") |
128 allow_comments = C.bool(mb_data.get('allow_comments', C.BOOL_FALSE)) | 129 allow_comments = C.bool(mb_data.get('allow_comments', C.BOOL_FALSE)) |
129 if allow_comments: | 130 if allow_comments: |
130 comments_service, comments_node = self._m.getCommentsService(client), self._m.getCommentsNode(mb_data['id']) | 131 comments_service = yield self._m.getCommentsService(client) |
132 comments_node = self._m.getCommentsNode(mb_data['id']) | |
131 mb_data['comments_service'] = comments_service.full() | 133 mb_data['comments_service'] = comments_service.full() |
132 mb_data['comments_node'] = comments_node | 134 mb_data['comments_node'] = comments_node |
133 recurse_kwargs = { | 135 recurse_kwargs = { |
134 'items_import_data':item_import_data['comments'][0], | 136 'items_import_data':item_import_data['comments'][0], |
135 'service':comments_service, | 137 'service':comments_service, |
136 'node':comments_node} | 138 'node':comments_node} |
137 return recurse_kwargs | 139 defer.returnValue(recurse_kwargs) |
138 else: | 140 else: |
139 if item_import_data['comments'][0]: | 141 if item_import_data['comments'][0]: |
140 raise exceptions.DataError(u"allow_comments set to False, but comments are there") | 142 raise exceptions.DataError(u"allow_comments set to False, but comments are there") |
141 return None | 143 defer.returnValue(None) |
142 | 144 |
143 def publishItem(self, client, mb_data, service, node, session): | 145 def publishItem(self, client, mb_data, service, node, session): |
144 log.debug(u"uploading item [{id}]: {title}".format(id=mb_data['id'], title=mb_data.get('title',''))) | 146 log.debug(u"uploading item [{id}]: {title}".format(id=mb_data['id'], title=mb_data.get('title',''))) |
145 return self._m.send(client, mb_data, service, node) | 147 return self._m.send(client, mb_data, service, node) |
146 | 148 |