backport stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 01 Oct 2010 11:24:21 +0200
changeset 6376 f8662240ed4d
parent 6373 41793f2718ce (current diff)
parent 6375 df4fd2a1b0e7 (diff)
child 6377 3bb415310d4f
backport stable
hooks/integrity.py
utils.py
--- a/hooks/integrity.py	Fri Oct 01 09:26:17 2010 +0200
+++ b/hooks/integrity.py	Fri Oct 01 11:24:21 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 09:26:17 2010 +0200
+++ b/schema.py	Fri Oct 01 11:24:21 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((
--- a/utils.py	Fri Oct 01 09:26:17 2010 +0200
+++ b/utils.py	Fri Oct 01 11:24:21 2010 +0200
@@ -166,6 +166,9 @@
         return repeat(self._item, self._size)
     def __getitem__(self, index):
         return self._item
+    def __delitem__(self, idc):
+        assert self._size > 0
+        self._size -= 1
     def __getslice__(self, i, j):
         # XXX could be more efficient, but do we bother?
         return ([self._item] * self._size)[i:j]