|
@@ -7,7 +7,7 @@ from .utils import get_connection_args, connect, collection_prefix, object_colle
|
7
|
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
|
11
|
|
12
|
12
|
class MigrationHandlerChangeError(Exception):
|
13
|
13
|
pass
|
|
@@ -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(editorial_model, conn_args=None):
|
|
20
|
+def mongodb_mh_init_db(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 = MongoDbMigrationHandler(connection_args)
|
|
22
|
+ migration_handler = MongoDbMigrationHandler(conn_args=connection_args)
|
23
|
23
|
migration_handler._install_collections()
|
24
|
24
|
migration_handler.database.close()
|
25
|
25
|
|
|
@@ -38,9 +38,6 @@ class MongoDbMigrationHandler(object):
|
38
|
38
|
|
39
|
39
|
conn_args = get_connection_args() if conn_args is None else conn_args
|
40
|
40
|
|
41
|
|
- if editorial_model is None:
|
42
|
|
- raise MongoDbMigrationHandler("Missing editorial model")
|
43
|
|
-
|
44
|
41
|
if len(conn_args.keys()) == 0:
|
45
|
42
|
raise MigrationHandlerError("No connection arguments were given")
|
46
|
43
|
|
|
@@ -67,7 +64,9 @@ class MongoDbMigrationHandler(object):
|
67
|
64
|
def _set_init_collection_names(self):
|
68
|
65
|
collection_names = ['relation']
|
69
|
66
|
for dynclass in dynclasses:
|
70
|
|
- if dynclass._abstract:
|
|
67
|
+ if dynclass._abstract \
|
|
68
|
+ and isinstance(dynclass._ro_datasource,MongoDbDatasource) \
|
|
69
|
+ and isinstance(dynclass._rw_datasource, MongoDbDatasource):
|
71
|
70
|
collection_names.append(dynclass.__name__)
|
72
|
71
|
return collection_names
|
73
|
72
|
|