[vreg] we must ensure that parent classes are initialiazed first stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 11 Sep 2009 12:35:19 +0200
branchstable
changeset 3172 9341ab8f1d1a
parent 3171 b10f0c1f3fe4
child 3178 3b2fae3109e1
[vreg] we must ensure that parent classes are initialiazed first
cwvreg.py
--- a/cwvreg.py	Fri Sep 11 12:34:55 2009 +0200
+++ b/cwvreg.py	Fri Sep 11 12:35:19 2009 +0200
@@ -130,19 +130,23 @@
         baseschemas = [eschema] + eschema.ancestors()
         # browse ancestors from most specific to most generic and try to find an
         # associated custom entity class
+        cls = None
         for baseschema in baseschemas:
             try:
                 btype = ETYPE_NAME_MAP[baseschema]
             except KeyError:
                 btype = str(baseschema)
-            try:
-                objects = self[btype]
-                assert len(objects) == 1, objects
-                cls = objects[0]
-                break
-            except ObjectNotFound:
-                pass
-        else:
+            if cls is None:
+                try:
+                    objects = self[btype]
+                    assert len(objects) == 1, objects
+                    cls = objects[0]
+                except ObjectNotFound:
+                    pass
+            else:
+                # ensure parent classes are built first
+                self.etype_class(btype)
+        if cls is None:
             # no entity class for any of the ancestors, fallback to the default
             # one
             objects = self['Any']