[migration] Disable hooks during migration
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 20 Jan 2017 17:40:30 +0100
changeset 2318 acfd23149a9e
parent 2317 e66d8c8b3a4b
child 2322 9cd918201ab8
[migration] Disable hooks during migration
migration/0.6.0_Any.py
--- a/migration/0.6.0_Any.py	Fri Jan 20 14:54:31 2017 +0100
+++ b/migration/0.6.0_Any.py	Fri Jan 20 17:40:30 2017 +0100
@@ -1,14 +1,15 @@
 from cubicweb.schema import META_RTYPES
 
-scheme = cnx.find('ConceptScheme', title=u'SEDA : Niveaux de description').one()
-for concept in scheme.reverse_in_scheme:
-    seda_label = concept.labels['seda']
-    seda2_label = {'recordgrp': u'RecordGrp',
-                   'subgrp': u'SubGrp'}.get(seda_label, seda_label.capitalize())
-    cnx.create_entity('Label', label_of=concept,
-                      kind=u'preferred', language_code=u'seda-2',
-                      label=seda2_label)
-commit()
+with cnx.deny_all_hooks_but('metadata'):
+    scheme = cnx.find('ConceptScheme', title=u'SEDA : Niveaux de description').one()
+    for concept in scheme.reverse_in_scheme:
+        seda_label = concept.labels['seda']
+        seda2_label = {'recordgrp': u'RecordGrp',
+                       'subgrp': u'SubGrp'}.get(seda_label, seda_label.capitalize())
+        cnx.create_entity('Label', label_of=concept,
+                          kind=u'preferred', language_code=u'seda-2',
+                          label=seda2_label)
+    commit()
 
 sync_schema_props_perms(('SEDAArchiveTransfer', 'title', 'String'))
 
@@ -50,6 +51,7 @@
     drop_entity_type('Agent')
 
 add_attribute('SEDAKeyword', 'keyword_content')
-rql('SET KW keyword_content C WHERE KWC seda_keyword_content KW, KWC keyword_content C')
+with cnx.deny_all_hooks_but():
+    rql('SET KW keyword_content C WHERE KWC seda_keyword_content KW, KWC keyword_content C')
 commit()
 drop_entity_type('SEDAKeywordContent')