Return None, None in parent_and_container() instead of crashing
authorDenis Laxalde <denis.laxalde@logilab.fr>
Wed, 24 Apr 2019 17:49:29 +0200
changeset 3000 e9dd2397f4ef
parent 2986 928947277217
child 3001 587b718f1284
Return None, None in parent_and_container() instead of crashing Still log the information, just in case...
cubicweb_seda/entities/__init__.py
--- a/cubicweb_seda/entities/__init__.py	Fri Mar 08 14:27:41 2019 +0100
+++ b/cubicweb_seda/entities/__init__.py	Wed Apr 24 17:49:29 2019 +0200
@@ -42,7 +42,10 @@
         parent = entity.cw_adapt_to('IContained').parent
         if container is None:
             # entity may be both container and contained, and in this case is a container
-            assert entity.cw_adapt_to('IContainer'), entity
+            if entity.cw_adapt_to('IContainer') is None:
+                entity.debug('cannot adapt %s as IContainer in parent_and_container()',
+                             entity)
+                return None, None
             container = entity
     else:
         req = entity._cw