do not check for existant entity when relation of single card is added but integrity hooks are deactivated stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 02 Mar 2010 15:57:32 +0100
branchstable
changeset 4756 a2c73b272c9b
parent 4755 13a5d3a7410e
child 4757 5d937aeaa6fb
do not check for existant entity when relation of single card is added but integrity hooks are deactivated
server/repository.py
server/serverconfig.py
--- a/server/repository.py	Tue Mar 02 15:44:26 2010 +0100
+++ b/server/repository.py	Tue Mar 02 15:57:32 2010 +0100
@@ -105,7 +105,8 @@
     #     skip that for super session (though we can still skip it for internal
     #     sessions). Also we should imo rely on the orm to first fetch existing
     #     entity if any then delete it.
-    if session.is_internal_session:
+    if session.is_internal_session \
+           or not session.vreg.config.is_hook_category_activated('integrity'):
         return
     card = session.schema_rproperty(rtype, eidfrom, eidto, 'cardinality')
     # one may be tented to check for neweids but this may cause more than one
--- a/server/serverconfig.py	Tue Mar 02 15:44:26 2010 +0100
+++ b/server/serverconfig.py	Tue Mar 02 15:57:32 2010 +0100
@@ -185,6 +185,8 @@
     # check user's state at login time
     consider_user_state = True
 
+    # XXX hooks control stuff should probably be on the session, not on the config
+
     # hooks activation configuration
     # all hooks should be activated during normal execution
     disabled_hooks_categories = set()
@@ -232,9 +234,13 @@
 
     @classmethod
     def is_hook_activated(cls, hook):
+        return cls.is_hook_category_activated(hook.category)
+
+    @classmethod
+    def is_hook_category_activated(cls, category):
         if cls.hooks_mode is cls.DENY_ALL:
-            return hook.category in cls.enabled_hooks_categories
-        return hook.category not in cls.disabled_hooks_categories
+            return category in cls.enabled_hooks_categories
+        return category not in cls.disabled_hooks_categories
 
     # should some hooks be deactivated during [pre|post]create script execution
     free_wheel = False