Browse Source

Merge branch 'newlodel' of git.labocleo.org:lodel2 into newlodel

prieto 8 years ago
parent
commit
2e01764b67

+ 5
- 5
lodel/leapi/datahandlers/base_classes.py View File

@@ -99,15 +99,15 @@ class DataHandler(object):
99 99
     # @throw RunTimeError if data construction fails
100 100
     def construct_data(self, emcomponent, fname, datas, cur_value):
101 101
         emcomponent_fields = emcomponent.fields()
102
-        fname_data_handler = None
102
+        data_handler = None
103 103
         if fname in emcomponent_fields:
104
-            fname_data_handler = DataHandler.from_name(emcomponent_fields[fname])
104
+            data_handler = emcomponent_fields[fname]
105 105
 
106 106
         if fname in datas.keys():
107 107
             return cur_value
108
-        elif fname_data_handler is not None and hasattr(fname_data_handler, 'default'):
109
-                return fname_data_handler.default
110
-        elif fname_data_handler is not None and fname_data_handler.nullable:
108
+        elif data_handler is not None and hasattr(data_handler, 'default'):
109
+                return data_handler.default
110
+        elif data_handler is not None and data_handler.nullable:
111 111
                 return None
112 112
 
113 113
         return RuntimeError("Unable to construct data for field %s", fname)

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

@@ -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
 

Loading…
Cancel
Save