[repo] Don't crash on start when fs schema is missing some db schema entities
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 26 May 2016 15:38:39 +0200
changeset 11477 3b4d41566de3
parent 11476 a9f26de5ea6c
child 11478 1817f8946c22
[repo] Don't crash on start when fs schema is missing some db schema entities This occurs usually while developping and we don't want systematically to rebuild the database to start the instance or run e.g. i18ninstance.
cubicweb/server/repository.py
--- a/cubicweb/server/repository.py	Fri Sep 23 13:36:06 2016 +0200
+++ b/cubicweb/server/repository.py	Thu May 26 15:38:39 2016 +0200
@@ -234,7 +234,12 @@
                 # set eids on entities schema
                 with self.internal_cnx() as cnx:
                     for etype, eid in cnx.execute('Any XN,X WHERE X is CWEType, X name XN'):
-                        self.schema.eschema(etype).eid = eid
+                        try:
+                            self.schema.eschema(etype).eid = eid
+                        except KeyError:
+                            # etype in the database doesn't exist in the fs schema, this may occur
+                            # during dev and we shouldn't crash
+                            self.warning('No %s entity type in the file system schema', etype)
         else:
             # normal start: load the instance schema from the database
             self.info('loading schema from the repository')