Browse Source

Bugfix in init_db method of MongoDB migration handler

Yann Weber 8 years ago
parent
commit
ba3f660451
1 changed files with 7 additions and 6 deletions
  1. 7
    6
      plugins/mongodb_datasource/migration_handler.py

+ 7
- 6
plugins/mongodb_datasource/migration_handler.py View File

@@ -8,6 +8,7 @@ from lodel.leapi.datahandlers.base_classes import DataHandler
8 8
 from lodel.plugin import LodelHook
9 9
 from leapi_dyncode import *
10 10
 from .datasource import MongoDbDatasource
11
+from lodel import logger
11 12
 
12 13
 class MigrationHandlerChangeError(Exception):
13 14
     pass
@@ -49,6 +50,8 @@ class MigrationHandler(object):
49 50
             MigrationHandler.MIGRATION_HANDLER_DEFAULT_SETTINGS['drop_if_exists']
50 51
             
51 52
         self.init_collections_names = None
53
+        logger.debug("MongoDb migration handler instanciated on db : \
54
+%s@%s:%s" % (db_name, host, port))
52 55
         
53 56
     def _set_init_collection_names(self, emclass_list):
54 57
         collection_names = ['relation']
@@ -61,12 +64,10 @@ class MigrationHandler(object):
61 64
 
62 65
     ## @brief Installs the basis collections of the database
63 66
     def init_db(self, emclass_list):
64
-        self.init_collections_names(emclass_list)
65
-        init_collection_names = self.init_collections_names
66
-        for collection_name in init_collection_names:
67
-            prefix = collection_prefix['object'] if collection_name != 'relation' else collection_prefix['relation']
68
-            collection_to_create = "%s%s" % (prefix, collection_name)
69
-            self._create_collection(collection_name=collection_to_create)
67
+        for collection_name in [ object_collection_name(cls)
68
+            for cls in emclass_list]:
69
+            self._create_collection(collection_name)
70
+            logger.debug("Collection %s created" % collection_name)
70 71
 
71 72
     ## @brief Creates a collection in the database
72 73
     # @param collection_name str

Loading…
Cancel
Save