mirror of
https://github.com/yweber/lodel2.git
synced 2025-10-26 09:39:01 +01:00
Merge branch 'newlodel' of git.labocleo.org:lodel2 into newlodel
This commit is contained in:
commit
2e01764b67
2 changed files with 11 additions and 12 deletions
|
|
@ -99,15 +99,15 @@ class DataHandler(object):
|
|||
# @throw RunTimeError if data construction fails
|
||||
def construct_data(self, emcomponent, fname, datas, cur_value):
|
||||
emcomponent_fields = emcomponent.fields()
|
||||
fname_data_handler = None
|
||||
data_handler = None
|
||||
if fname in emcomponent_fields:
|
||||
fname_data_handler = DataHandler.from_name(emcomponent_fields[fname])
|
||||
data_handler = emcomponent_fields[fname]
|
||||
|
||||
if fname in datas.keys():
|
||||
return cur_value
|
||||
elif fname_data_handler is not None and hasattr(fname_data_handler, 'default'):
|
||||
return fname_data_handler.default
|
||||
elif fname_data_handler is not None and fname_data_handler.nullable:
|
||||
elif data_handler is not None and hasattr(data_handler, 'default'):
|
||||
return data_handler.default
|
||||
elif data_handler is not None and data_handler.nullable:
|
||||
return None
|
||||
|
||||
return RuntimeError("Unable to construct data for field %s", fname)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from .utils import get_connection_args, connect, collection_prefix, object_colle
|
|||
from lodel.leapi.datahandlers.base_classes import DataHandler
|
||||
from lodel.plugin import LodelHook
|
||||
from leapi_dyncode import *
|
||||
|
||||
from .datasource import MongoDbDatasource
|
||||
|
||||
class MigrationHandlerChangeError(Exception):
|
||||
pass
|
||||
|
|
@ -17,9 +17,9 @@ class MigrationHandlerError(Exception):
|
|||
pass
|
||||
|
||||
@LodelHook('mongodb_mh_init_db')
|
||||
def mongodb_mh_init_db(editorial_model, conn_args=None):
|
||||
def mongodb_mh_init_db(conn_args=None):
|
||||
connection_args = get_connection_args('default') if conn_args is None else get_connection_args(conn_args['name'])
|
||||
migration_handler = MongoDbMigrationHandler(connection_args)
|
||||
migration_handler = MongoDbMigrationHandler(conn_args=connection_args)
|
||||
migration_handler._install_collections()
|
||||
migration_handler.database.close()
|
||||
|
||||
|
|
@ -38,9 +38,6 @@ class MongoDbMigrationHandler(object):
|
|||
|
||||
conn_args = get_connection_args() if conn_args is None else conn_args
|
||||
|
||||
if editorial_model is None:
|
||||
raise MongoDbMigrationHandler("Missing editorial model")
|
||||
|
||||
if len(conn_args.keys()) == 0:
|
||||
raise MigrationHandlerError("No connection arguments were given")
|
||||
|
||||
|
|
@ -67,7 +64,9 @@ class MongoDbMigrationHandler(object):
|
|||
def _set_init_collection_names(self):
|
||||
collection_names = ['relation']
|
||||
for dynclass in dynclasses:
|
||||
if dynclass._abstract:
|
||||
if dynclass._abstract \
|
||||
and isinstance(dynclass._ro_datasource,MongoDbDatasource) \
|
||||
and isinstance(dynclass._rw_datasource, MongoDbDatasource):
|
||||
collection_names.append(dynclass.__name__)
|
||||
return collection_names
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue