[schema] introduce new WORKFLOW_RTYPES set and use it to build SYSTEM_RTYPES/DONT_CHECK_RTYPES_ON_ADD/DONT_CHECK_RTYPES_ON_DEL sets stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 01 Oct 2010 11:09:25 +0200
branchstable
changeset 6375 df4fd2a1b0e7
parent 6374 5adf53edfe12
child 6376 f8662240ed4d
child 6381 c9eed5037223
[schema] introduce new WORKFLOW_RTYPES set and use it to build SYSTEM_RTYPES/DONT_CHECK_RTYPES_ON_ADD/DONT_CHECK_RTYPES_ON_DEL sets
hooks/integrity.py
schema.py
--- a/hooks/integrity.py	Fri Oct 01 11:08:31 2010 +0200
+++ b/hooks/integrity.py	Fri Oct 01 11:09:25 2010 +0200
@@ -26,7 +26,8 @@
 from yams.schema import role_name
 
 from cubicweb import ValidationError
-from cubicweb.schema import RQLConstraint, RQLUniqueConstraint
+from cubicweb.schema import (META_RTYPES, WORKFLOW_RTYPES,
+                             RQLConstraint, RQLUniqueConstraint)
 from cubicweb.selectors import is_instance
 from cubicweb.uilib import soup2xhtml
 from cubicweb.server import hook
@@ -34,11 +35,8 @@
 
 # special relations that don't have to be checked for integrity, usually
 # because they are handled internally by hooks (so we trust ourselves)
-DONT_CHECK_RTYPES_ON_ADD = set(('owned_by', 'created_by',
-                                'is', 'is_instance_of',
-                                'wf_info_for', 'from_state', 'to_state'))
-DONT_CHECK_RTYPES_ON_DEL = set(('is', 'is_instance_of',
-                                'wf_info_for', 'from_state', 'to_state'))
+DONT_CHECK_RTYPES_ON_ADD = META_RTYPES | WORKFLOW_RTYPES
+DONT_CHECK_RTYPES_ON_DEL = META_RTYPES | WORKFLOW_RTYPES
 
 _UNIQUE_CONSTRAINTS_LOCK = Lock()
 _UNIQUE_CONSTRAINTS_HOLDER = None
--- a/schema.py	Fri Oct 01 11:08:31 2010 +0200
+++ b/schema.py	Fri Oct 01 11:09:25 2010 +0200
@@ -51,8 +51,8 @@
     'owned_by', 'created_by', 'is', 'is_instance_of', 'identity',
     'eid', 'creation_date', 'modification_date', 'has_text', 'cwuri',
     ))
-SYSTEM_RTYPES = set(('require_permission', 'custom_workflow', 'in_state',
-                     'wf_info_for'))
+WORKFLOW_RTYPES = set(('custom_workflow', 'in_state', 'wf_info_for'))
+SYSTEM_RTYPES = set(('require_permission',)) | WORKFLOW_RTYPES
 
 # set of entity and relation types used to build the schema
 SCHEMA_TYPES = set((