Changeset - d6acdf8470f4
[Not reviewed]
0 2 0
Lance Edgar (lance) - 7 years ago 2017-07-26 15:32:58
lance@edbob.org
Avoid session auto-flush when populating or refreshing a batch

this is primarily needed when continuum versioning is enabled, to make
sure things don't slow way down due to session flush hook
2 files changed with 6 insertions and 5 deletions:
0 comments (0 inline, 0 general)
rattail/batch/handlers.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
# -*- coding: utf-8; -*-
 
################################################################################
 
#
 
#  Rattail -- Retail Software Framework
 
@@ -99,7 +99,7 @@ class BatchHandler(object):
 
        session = orm.object_session(batch)
 
        with session.no_autoflush:
 
            batch.data_rows.append(row)
 
        self.refresh_row(row)
 
            self.refresh_row(row)
 
        if not row.removed:
 
            batch.rowcount += 1
 

	
 
@@ -230,11 +230,13 @@ class BatchHandler(object):
 
        such data will be left intact, with all *other* data values being
 
        re-calculated and/or reset etc.
 
        """
 
        session = orm.object_session(batch)
 
        self.setup_refresh(batch, progress=progress)
 
        batch.rowcount = 0
 

	
 
        def refresh(row, i):
 
            self.refresh_row(row)
 
            with session.no_autoflush:
 
                self.refresh_row(row)
 
            if not row.removed:
 
                batch.rowcount += 1
 

	
rattail/batch/vendorinvoice.py
Show inline comments
 
@@ -75,8 +75,7 @@ class VendorInvoiceHandler(BatchHandler):
 
        self.setup_populate(batch, progress=progress)
 

	
 
        def append(row, i):
 
            batch.add_row(row)
 
            self.refresh_row(row)
 
            self.add_row(batch, row)
 
            if i % 250 == 0:
 
                session.flush()
 

	
0 comments (0 inline, 0 general)