Fix AttributeError on postcommit when db-create adds non-system CWSource entities 3.24
authorFlorent Cayré <florent.cayre@logilab.fr>
Tue, 15 Nov 2016 12:20:02 +0100
branch3.24
changeset 11819 a85b7a898e13
parent 11818 fdc0a8260fd2
child 11820 ec612abc2e2e
Fix AttributeError on postcommit when db-create adds non-system CWSource entities In this case, `Repository.add_source` is called from an operation, not from `Repository.init_sources_from_database`, thus the attribute `sources_by_eid` does not exist. Closes #16251078.
cubicweb/server/repository.py
--- a/cubicweb/server/repository.py	Wed Nov 09 23:00:00 2016 +0100
+++ b/cubicweb/server/repository.py	Tue Nov 15 12:20:02 2016 +0100
@@ -157,6 +157,7 @@
 
     def __init__(self, config, tasks_manager=None, vreg=None):
         self.config = config
+        self.sources_by_eid = {}
         if vreg is None:
             vreg = cwvreg.CWRegistryStore(config)
         self.vreg = vreg
@@ -264,7 +265,6 @@
     # internals ###############################################################
 
     def init_sources_from_database(self):
-        self.sources_by_eid = {}
         if self.config.quick_start or 'CWSource' not in self.schema:  # 3.10 migration
             self.system_source.init_creating()
             return