|
@@ -17,9 +17,9 @@ class MigrationHandlerError(Exception):
|
17
|
17
|
pass
|
18
|
18
|
|
19
|
19
|
@LodelHook('mongodb_mh_init_db')
|
20
|
|
-def mongodb_mh_init_db(conn_args=None):
|
|
20
|
+def mongodb_mh_init_db(classes_list, conn_args=None):
|
21
|
21
|
connection_args = get_connection_args('default') if conn_args is None else get_connection_args(conn_args['name'])
|
22
|
|
- migration_handler = MigrationHandler(conn_args=connection_args)
|
|
22
|
+ migration_handler = MigrationHandler(classes_list, conn_args=connection_args)
|
23
|
23
|
migration_handler.init_db()
|
24
|
24
|
migration_handler.database.close()
|
25
|
25
|
|
|
@@ -32,8 +32,8 @@ class MigrationHandler(object):
|
32
|
32
|
## @brief Constructs a MongoDbMigrationHandler
|
33
|
33
|
# @param conn_args dict : a dictionary containing the connection options
|
34
|
34
|
# @param **kwargs : extra arguments
|
35
|
|
- def __init__(self, editorial_model=None, conn_args=None, **kwargs):
|
36
|
|
- self.editorial_model = editorial_model
|
|
35
|
+ def __init__(self, classes_list, conn_args=None, **kwargs):
|
|
36
|
+ self._classes_handled = classes_list
|
37
|
37
|
|
38
|
38
|
conn_args = get_connection_args() if conn_args is None else conn_args
|
39
|
39
|
|
|
@@ -60,8 +60,8 @@ class MigrationHandler(object):
|
60
|
60
|
|
61
|
61
|
def _set_init_collection_names(self):
|
62
|
62
|
collection_names = ['relation']
|
63
|
|
- for dynclass in dynclasses:
|
64
|
|
- if dynclass._abstract \
|
|
63
|
+ for dynclass in self._classes_handled:
|
|
64
|
+ if not dynclass._abstract \
|
65
|
65
|
and isinstance(dynclass._ro_datasource,MongoDbDatasource) \
|
66
|
66
|
and isinstance(dynclass._rw_datasource, MongoDbDatasource):
|
67
|
67
|
collection_names.append(dynclass.__name__)
|