[PATCH 2 of 5 saem_ref] Set AssignARKHook's category to "metadata"

Denis Laxalde denis.laxalde at logilab.fr
Wed Apr 11 16:30:06 CEST 2018

# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1523449034 -7200
#      Wed Apr 11 14:17:14 2018 +0200
# Node ID 1ff8b995857342b54188eb816b234bb9b958ad85
# Parent  e760c0a1d9b9745557512eec6b52d515e8d53d9a
# Available At http://hg.logilab.org/review/cubes/saem_ref
#              hg pull http://hg.logilab.org/review/cubes/saem_ref -r 1ff8b9958573
# EXP-Topic ark-for-archiveunit
Set AssignARKHook's category to "metadata"

The reason for this is that the IClonable adapter will disable all hooks
but that in "metadata" category. So when AssignARKHook is not in this
category, any entity that is cloned but needs an "ark" attribute (which
is obviously not copied as it must be unique) while not have an "ark"
assigned. This will become needed in forthcoming changesets in which and
"ark" attribute will be added to SEDAArchiveUnit entity type and which
is involved in clone operation of their respective archive transfer.

diff --git a/cubicweb_saem_ref/hooks.py b/cubicweb_saem_ref/hooks.py
--- a/cubicweb_saem_ref/hooks.py
+++ b/cubicweb_saem_ref/hooks.py
@@ -208,6 +208,7 @@ class AssignARKHook(hook.Hook):
     __select__ = hook.Hook.__select__ & relation_possible('ark')
     events = ('before_add_entity',)
     order = metadata.InitMetaAttrsHook.order - 1
+    category = 'metadata'
     def __call__(self):
         if not self.entity.cw_edited.get('ark'):

More information about the saem-devel mailing list