From 01e59d510ef299bdda8aa363be8662737a4dc7e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com> Date: Thu, 6 Feb 2020 15:13:52 +0100 Subject: [PATCH] update --- src/caosdb/apiutils.py | 4 ++-- src/caosdb/common/datatype.py | 4 ++-- src/caosdb/common/models.py | 12 +++++++----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/caosdb/apiutils.py b/src/caosdb/apiutils.py index 37599d57..3af9345e 100644 --- a/src/caosdb/apiutils.py +++ b/src/caosdb/apiutils.py @@ -86,11 +86,11 @@ def new_record(record_type, name=None, description=None, def id_query(ids): q = "FIND Entity with " + " OR ".join(["id={}".format(id) for id in ids]) - return db.execute_query(q) + return execute_query(q) def retrieve_entities_with_ids(entities): - collection = db.Container() + collection = Container() step = 20 for i in range(len(entities)//step+1): diff --git a/src/caosdb/common/datatype.py b/src/caosdb/common/datatype.py index f40b79f9..23b01a8a 100644 --- a/src/caosdb/common/datatype.py +++ b/src/caosdb/common/datatype.py @@ -43,7 +43,7 @@ def LIST(datatype): def get_list_datatype(datatype): """ returns the datatype of the elements in the list """ - match = re.match("LIST(<|<)(?P<datatype>.*)(>|>)", "LISTING") + match = re.match("LIST(<|<)(?P<datatype>.*)(>|>)", datatype) if match is not None: return match.group("datatype") @@ -109,7 +109,7 @@ def get_id_of_datatype(datatype): raise AmbiguityException( "Name {} did not lead to unique result; Missing " "implementation".format(datatype)) - elif len(res) == 1: + elif len(res) != 1: raise EntityDoesNotExistError( "No RecordType named {}".format(datatype)) diff --git a/src/caosdb/common/models.py b/src/caosdb/common/models.py index f9d4f2b0..32343680 100644 --- a/src/caosdb/common/models.py +++ b/src/caosdb/common/models.py @@ -38,8 +38,8 @@ from sys import hexversion from tempfile import NamedTemporaryFile from warnings import warn -from lxml import etree -from .datatype import is_reference +from caosdb.common.datatype import (BOOLEAN, DATETIME, DOUBLE, FILE, INTEGER, + LIST, REFERENCE, TEXT, is_reference) from caosdb.common.utils import uuid, xml2str from caosdb.configuration import get_config from caosdb.connection.connection import get_connection @@ -50,8 +50,9 @@ from caosdb.exceptions import (AmbiguityException, AuthorizationException, EntityHasNoDatatypeError, TransactionError, UniqueNamesError, UnqualifiedParentsError, UnqualifiedPropertiesError, URITooLongException) -from caosdb.common.datatype import (BOOLEAN, DATETIME, DOUBLE, FILE, INTEGER, - LIST, REFERENCE, TEXT, is_reference) +from lxml import etree + +from .datatype import is_reference _ENTITY_URI_SEGMENT = "Entity" @@ -953,7 +954,8 @@ class Entity(object): if isinstance(prop.value, list): prop.value = [func(el) for el in prop.value] else: - prop.value = func(prop.value) + if prop.value is not None: + prop.value = func(prop.value) def _parse_col_values(cdt, vals): -- GitLab