Make the component_unit predicate work with non seda entities
authorFrank Bessou <frank.bessou@logilab.fr>
Thu, 27 Sep 2018 15:34:17 +0200
changeset 2962 4f0b259e419e
parent 2958 01c4f249e161
child 2963 0b663b4c509f
Make the component_unit predicate work with non seda entities In the component_unit predicate, we handle the case where _seda_container_from_context returns None by returning 0. This can be the case when the predicate is called with a non seda entity.
cubicweb_seda/entities/__init__.py
--- a/cubicweb_seda/entities/__init__.py	Tue Jun 26 14:20:19 2018 +0200
+++ b/cubicweb_seda/entities/__init__.py	Thu Sep 27 15:34:17 2018 +0200
@@ -97,7 +97,9 @@
     container root is not a SEDAArchiveTransfer but a SEDAArchiveUnit).
     """
     entity = _seda_container_from_context(rset, entity, **kwargs)
-    return 1 if entity.cw_etype == 'SEDAArchiveUnit' else 0
+    if entity and entity.cw_etype == 'SEDAArchiveUnit':
+        return 1
+    return 0
 
 
 @objectify_predicate