on precommit / rollback of schema update op, clear order_relations cache of entity schemas stable cubicweb-version-3.5.5
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 21 Oct 2009 15:13:07 +0200
branchstable
changeset 3774 1eca47d59fd9
parent 3773 14fde27a70a2
child 3775 aad818d9d9b6
on precommit / rollback of schema update op, clear order_relations cache of entity schemas
server/schemahooks.py
--- a/server/schemahooks.py	Wed Oct 21 15:12:29 2009 +0200
+++ b/server/schemahooks.py	Wed Oct 21 15:13:07 2009 +0200
@@ -16,6 +16,7 @@
 from yams.buildobjs import EntityType, RelationType, RelationDefinition
 from yams.schema2sql import eschema2sql, rschema2sql, type_from_constraints
 
+from logilab.common.decorators import clear_cache
 
 from cubicweb import ValidationError, RepositoryError
 from cubicweb.schema import META_RTYPES, VIRTUAL_RTYPES, CONSTRAINTS
@@ -134,10 +135,18 @@
         self.repo = session.repo
         SingleLastOperation.__init__(self, session)
 
+    def precommit_event(self):
+        for eschema in self.repo.schema.entities():
+            if not eschema.final:
+                clear_cache(eschema, 'ordered_relations')
+
     def commit_event(self):
         rebuildinfered = self.session.data.get('rebuild-infered', True)
         self.repo.set_schema(self.repo.schema, rebuildinfered=rebuildinfered)
 
+    def rollback_event(self):
+        self.precommit_event()
+
 
 class MemSchemaOperation(Operation):
     """base class for schema operations"""