# HG changeset patch # User Adrien Di Mascio # Date 1476364598 -7200 # Node ID 20555214576bca9a89cef371a961c8ad897d165b # Parent 04607da552ac0b95cfc9e80740192ac2560c8dc3 [massive store] master_init should commit by default Default client usage is to create a master store to control slave ones. They need to access cwmassive_initialized from another transaction diff -r 04607da552ac -r 20555214576b cubicweb/dataimport/massive_store.py --- a/cubicweb/dataimport/massive_store.py Thu Oct 13 15:12:33 2016 +0200 +++ b/cubicweb/dataimport/massive_store.py Thu Oct 13 15:16:38 2016 +0200 @@ -108,7 +108,7 @@ # master/slaves specific API - def master_init(self): + def master_init(self, commit=True): """Initialize database for massive insertion. This is expected to be called once, by the master store in master/slaves configuration. @@ -118,6 +118,8 @@ self.sql('CREATE TABLE cwmassive_initialized' '(retype text, type varchar(128), uuid varchar(32))') self._initialized[self] = None + if commit: + self.commit() # SQL utilities ######################################################### @@ -149,7 +151,7 @@ """ if etype not in self._initialized: if not self.slave_mode: - self.master_init() + self.master_init(commit=False) tablename = 'cw_%s' % etype.lower() tmp_tablename = '%s_%s' % (tablename, self.uuid) self.sql("INSERT INTO cwmassive_initialized VALUES (%(e)s, 'etype', %(uuid)s)", @@ -175,7 +177,7 @@ """ if rtype not in self._initialized: if not self.slave_mode: - self.master_init() + self.master_init(commit=False) assert not self._cnx.vreg.schema.rschema(rtype).inlined self._initialized[rtype] = None tablename = '%s_relation' % rtype.lower()