[schema sync] fix so that new cardinality are considered when both inlined and cardinality change in the same transaction stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 21 Sep 2009 19:44:08 +0200
branchstable
changeset 3353 1003a6f3d298
parent 3351 2ea19d969a2d
child 3354 663bd041f17d
[schema sync] fix so that new cardinality are considered when both inlined and cardinality change in the same transaction
entities/schemaobjs.py
--- a/entities/schemaobjs.py	Mon Sep 21 18:49:38 2009 +0200
+++ b/entities/schemaobjs.py	Mon Sep 21 19:44:08 2009 +0200
@@ -63,14 +63,18 @@
         * raise ValidationError if inlining is'nt possible
         * eventually return True
         """
-        rtype = self.name
-        rschema = self.schema.rschema(rtype)
+        rschema = self.schema.rschema(self.name)
         if inlined == rschema.inlined:
             return False
         if inlined:
-            for (stype, otype) in rschema.iter_rdefs():
-                card = rschema.rproperty(stype, otype, 'cardinality')[0]
+            # don't use the persistent schema, we may miss cardinality changes
+            # in the same transaction
+            for rdef in self.reverse_relation_type:
+                card = rdef.cardinality[0]
                 if not card in '?1':
+                    rtype = self.name
+                    stype = rdef.stype
+                    otype = rdef.otype
                     msg = self.req._("can't set inlined=%(inlined)s, "
                                      "%(stype)s %(rtype)s %(otype)s "
                                      "has cardinality=%(card)s")