def update(self, changed_workflows, reindex_security=True, savepoints=None): types = self.get_suspected_types(changed_workflows) objects = SavepointIterator.build(self.lookup_objects(types), savepoints) for obj in objects: if self.obj_has_workflow(obj, changed_workflows): update_security_for(obj, reindex_security=reindex_security)
def objects(self, catalog_query, message, logger=None, savepoints=None): """Queries the catalog (unrestricted) and an iterator with full objects. The iterator configures and calls a ``ProgressLogger`` with the passed ``message``. """ objects = self.catalog_unrestricted_search(catalog_query, full_objects=True) objects = SavepointIterator.build(objects, savepoints, logger) return ProgressLogger(message, objects, logger=logger)
def objects(self, catalog_query, message, logger=None, savepoints=None): """Queries the catalog (unrestricted) and an iterator with full objects. The iterator configures and calls a ``ProgressLogger`` with the passed ``message``. """ objects = self.catalog_unrestricted_search( catalog_query, full_objects=True) objects = SavepointIterator.build(objects, savepoints, logger) return ProgressLogger(message, objects, logger=logger)
def test_doesnt_create_savepoints_with_threshold_0(self): self.assertEqual( 0, self.txn._savepoint_index, 'A new transaction should not have any savepoints yet') iterator = SavepointIterator.build(self.iterable, threshold=0) # Consume entire iterator result = list(iterator) self.assertEqual(self.iterable, result, 'Iterator should yield every item of `iterable`') self.assertEqual(0, self.txn._savepoint_index, 'threshold=0 should never create any savepoints')
def test_creates_savepoints(self): self.assertEqual( 0, self.txn._savepoint_index, 'A new transaction should not have any savepoints yet') iterator = SavepointIterator.build(self.iterable, threshold=5) # Consume entire iterator result = list(iterator) self.assertEqual(self.iterable, result, 'Iterator should yield every item of `iterable`') self.assertEqual(1, self.txn._savepoint_index, 'One savepoint should have been created')
def test_doesnt_create_savepoints_with_threshold_0(self): self.assertEquals( 0, self.txn._savepoint_index, 'A new transaction should not have any savepoints yet') iterator = SavepointIterator.build(self.iterable, threshold=0) # Consume entire iterator result = list(iterator) self.assertEquals( self.iterable, result, 'Iterator should yield every item of `iterable`') self.assertEquals( 0, self.txn._savepoint_index, 'threshold=0 should never create any savepoints')
def test_creates_savepoints(self): self.assertEquals( 0, self.txn._savepoint_index, 'A new transaction should not have any savepoints yet') iterator = SavepointIterator.build(self.iterable, threshold=5) # Consume entire iterator result = list(iterator) self.assertEquals( self.iterable, result, 'Iterator should yield every item of `iterable`') self.assertEquals( 1, self.txn._savepoint_index, 'One savepoint should have been created')