place the disable hooks context manager at the right place (closes: #1626694) oldstable
authorAlexandre Fayolle <alexandre.fayolle@logilab.fr>
Wed, 27 Apr 2011 16:10:10 +0200
brancholdstable
changeset 7261 1d1446e9dfe2
parent 7258 2e7f0d6fa2d6
child 7262 373212d1fa33
child 7269 de8ae247bb04
place the disable hooks context manager at the right place (closes: #1626694) hooks control is reset at each commit so we need to have a smaller scope for the CM in the 3.10.9 migration script
misc/migration/3.10.9_Any.py
--- a/misc/migration/3.10.9_Any.py	Thu Apr 28 08:18:48 2011 +0200
+++ b/misc/migration/3.10.9_Any.py	Wed Apr 27 16:10:10 2011 +0200
@@ -15,14 +15,14 @@
     nbops = rset.rowcount
     enabled = interactive_mode
     with progress(title=title, nbops=nbops, size=30, enabled=enabled) as pb:
-        with hooks_control(session, session.HOOKS_DENY_ALL, 'integrity'):
-            for i,  row in enumerate(rset):
+        for i,  row in enumerate(rset):
+            with hooks_control(session, session.HOOKS_DENY_ALL, 'integrity'):
                 data = {'eid': row[0], 'cwuri': row[1].replace(u'/eid', u'')}
                 rql('SET X cwuri %(cwuri)s WHERE X eid %(eid)s', data)
-                if not i % 100: # commit every 100 entities to limit memory consumption
-                    pb.text = "%i committed" % i
-                    commit(ask_confirm=False)
-                pb.update()
+            if not i % 100: # commit every 100 entities to limit memory consumption
+                pb.text = "%i committed" % i
+                commit(ask_confirm=False)
+            pb.update()
         commit(ask_confirm=False)
 
 try: