cwvreg.py
branch3.5
changeset 3184 613064b49331
parent 3071 6ad4e6d4df86
parent 3172 9341ab8f1d1a
child 3185 bd0126d17e83
child 3205 dc67e9431f34
--- a/cwvreg.py	Fri Sep 11 12:42:37 2009 +0200
+++ b/cwvreg.py	Fri Sep 11 15:55:15 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']