diff src/plugins/plugin_import.py @ 2390:f57a8eaec8ed

plugins import, tickets import, bugzilla import: comments handling: - comments are put in "comments" key in import data, it's a list of microblog data - in resulting item, the comments uri is put in comments_uri field - (plugin import) root_service and root_node are kept in session - (plugin ticket) reporter name is now in "reporter" key instead of "reporter_name" - (plugin bugizlla): if not reporter name is found, first part of email address is used
author Goffi <goffi@goffi.org>
date Fri, 20 Oct 2017 08:48:41 +0200
parents 2c2b826b0bb3
children 66baa687c682
line wrap: on
line diff
--- a/src/plugins/plugin_import.py	Fri Oct 20 08:44:09 2017 +0200
+++ b/src/plugins/plugin_import.py	Fri Oct 20 08:48:41 2017 +0200
@@ -53,8 +53,10 @@
         @param import_handler(object): specialized import handler instance
             must have the following methods:
                 - importItem: import a single main item (i.e. prepare data for publishing)
-                - importSubitems: import sub items (i.e. items linked to main item, e.g. comments). Must return a dict with kwargs for recursiveImport if items are to be imported. At east "items_import_data", "service" and "node" keys must be provided.
-                    if None is returned, no subitems will be imported
+                - importSubitems: import sub items (i.e. items linked to main item, e.g. comments).
+                    Must return a dict with kwargs for recursiveImport if items are to be imported recursively.
+                    At least "items_import_data", "service" and "node" keys must be provided.
+                    if None is returned, no recursion will be done to import subitems, but import can still be done directly by the method.
                 - publishItem: actualy publish an item
                 - itemFilters: modify item according to options
         @param name(unicode): import handler name
@@ -139,6 +141,7 @@
                 else:
                     if not value:
                         del options[opt_name]
+
         try:
             importer = import_handler.importers[name]
         except KeyError:
@@ -159,7 +162,10 @@
                    }
         self.host.registerProgressCb(progress_id, partial(self.getProgress, import_handler), metadata, profile=client.profile)
         self.host.bridge.progressStarted(progress_id, metadata, client.profile)
-        session = {}  # session data, can be use by importers
+        session = {  # session data, can be used by importers
+            u'root_service': pubsub_service,
+            u'root_node': pubsub_node
+        }
         self.recursiveImport(client, import_handler, items_import_data, progress_id, session, options, None, pubsub_service, pubsub_node)
         defer.returnValue(progress_id)
 
@@ -172,6 +178,7 @@
         @param progress_id(unicode): id of progression
         @param session(dict): data for this import session
             can be used by importer so store any useful data
+            "root_service" and "root_node" are set to the main pubsub service and node of the import
         @param options(dict): import options
         @param return_data(dict): data to return on progressFinished
         @param service(jid.JID, None): PubSub service to use