Refactor conditional logic in SimplifiedProfileDelRefROHook a bit
authorDenis Laxalde <denis.laxalde@logilab.fr>
Fri, 14 Dec 2018 09:39:19 +0100
changeset 2980 049322b9d8ee
parent 2979 181f83e6b545
child 2981 30e67f4f9e29
Refactor conditional logic in SimplifiedProfileDelRefROHook a bit This is a preparatory refactoring to ease introduction of a functional change in the next changeset.
cubicweb_seda/hooks.py
--- a/cubicweb_seda/hooks.py	Thu Nov 29 09:52:27 2018 +0100
+++ b/cubicweb_seda/hooks.py	Fri Dec 14 09:39:19 2018 +0100
@@ -310,9 +310,11 @@
         ref = self._cw.entity_from_eid(self.eidfrom)
         bdo = self._cw.entity_from_eid(self.eidto)
         if ref.cw_etype == 'SEDADataObjectReference' and bdo.cw_etype == 'SEDABinaryDataObject':
-            container = bdo.seda_binary_data_object[0] if bdo.seda_binary_data_object else None
-            if container and container.simplified_profile:
-                SimplifiedProfileDelRefROOp(self._cw, do_ref=ref, do=bdo)
+            if bdo.seda_binary_data_object:
+                container = bdo.seda_binary_data_object[0]
+                if not container.simplified_profile:
+                    return
+            SimplifiedProfileDelRefROOp(self._cw, do_ref=ref, do=bdo)
 
 
 class SimplifiedProfileDelRefROOp(hook.Operation):