# HG changeset patch # User Julien Cristau # Date 1449066243 -3600 # Node ID 66f94d7f9ca7280733f9e92b9d918cbdc49e526b # Parent ec5eeb08f2e8c89847b998a83bc34371c1ead3d8 [dataimport] make eids_seq_range as massive store instance attribute again I changed it to a class attribute recently, but on further thought (and prompting from Adrien) it seems to make more sense as an instance attribute. diff -r ec5eeb08f2e8 -r 66f94d7f9ca7 dataimport/massive_store.py --- a/dataimport/massive_store.py Wed Dec 02 15:20:52 2015 +0100 +++ b/dataimport/massive_store.py Wed Dec 02 15:24:03 2015 +0100 @@ -82,24 +82,25 @@ store.commit() store.finish() """ - # size of eid range reserved by the store for each batch - eids_seq_range = 10000 # max size of the iid, used to create the iid_eid conversion table iid_maxsize = 1024 def __init__(self, cnx, on_commit_callback=None, on_rollback_callback=None, slave_mode=False, - source=None): + source=None, + eids_seq_range=10000): """ Create a MassiveObject store, with the following attributes: - cnx: CubicWeb cnx + - eids_seq_range: size of eid range reserved by the store for each batch """ super(MassiveObjectStore, self).__init__(cnx) self.logger = logging.getLogger('dataimport.massive_store') self._cnx = cnx self.sql = cnx.system_sql self._data_uri_relations = defaultdict(list) + self.eids_seq_range = eids_seq_range # etypes for which we have a uri_eid_%(etype)s table self._init_uri_eid = set() diff -r ec5eeb08f2e8 -r 66f94d7f9ca7 dataimport/test/test_massive_store.py --- a/dataimport/test/test_massive_store.py Wed Dec 02 15:20:52 2015 +0100 +++ b/dataimport/test/test_massive_store.py Wed Dec 02 15:24:03 2015 +0100 @@ -130,11 +130,8 @@ self.assertIn('owned_by_relation_to_idx', indexes) def test_eids_seq_range(self): - class MyMassiveObjectStore(MassiveObjectStore): - eids_seq_range = 1000 - with self.admin_access.repo_cnx() as cnx: - store = MyMassiveObjectStore(cnx) + store = MassiveObjectStore(cnx, eids_seq_range=1000) store.restart_eid_sequence(50000) store.prepare_insert_entity('Location', name=u'toto') store.flush() @@ -144,11 +141,8 @@ self.assertGreater(crs.fetchone()[0], 50000) def test_eid_entity(self): - class MyMassiveObjectStore(MassiveObjectStore): - eids_seq_range = 1000 - with self.admin_access.repo_cnx() as cnx: - store = MyMassiveObjectStore(cnx) + store = MassiveObjectStore(cnx, eids_seq_range=1000) store.restart_eid_sequence(50000) eid = store.prepare_insert_entity('Location', name=u'toto') store.flush()