[saem-devel] [PATCH] Fix safety belt in UpdateModificationDateOp

Denis Laxalde denis.laxalde at logilab.fr
Tue Jan 24 16:34:27 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1484932941 -3600
#      Fri Jan 20 18:22:21 2017 +0100
# Node ID ad262c9f0fb3fabb98db9b0986eec4864babcf9b
# Parent  37af40bc48cbfd2ad7ddb20d214d084623bfabfe
Fix safety belt in UpdateModificationDateOp

and add a warning when it's used.

diff --git a/hooks.py b/hooks.py
--- a/hooks.py
+++ b/hooks.py
@@ -142,15 +142,18 @@ class UpdateModificationDateOp(hook.Data
         modification date at commit time.
         """
         self.add_data(entity.eid)
+        safety_belt = set((entity.eid,))
         while True:
-            safety_belt = set((entity.eid,))
             contained = entity.cw_adapt_to('IContained')
             if contained is None:
                 assert entity.cw_adapt_to('IContainer')
                 break
             else:
                 entity = contained.parent
-                if entity is None or entity.eid in safety_belt:
+                if entity is None:
+                    break
+                if entity.eid in safety_belt:
+                    self.warning('loop detected implying %s(%s)', entity.cw_etype, entity.eid)
                     break
                 self.add_data(entity.eid)
                 safety_belt.add(entity.eid)


More information about the saem-devel mailing list