Changeset 1764 in products


Ignore:
Timestamp:
Feb 17, 2010 8:08:50 PM (14 years ago)
Author:
mylan
Message:

Added subtransaction support to utility

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.catalogupdater/trunk/quintagroup/catalogupdater/utility.py

    r1755 r1764  
    11import logging, types 
     2import transaction 
    23from zope.interface import implements 
    34from zope.component import queryMultiAdapter 
     
    7273        schema = _catalog.schema 
    7374        paths = _catalog.paths 
     75        # For subtransaction support 
     76        threshold = getattr(catalog, 'threshold', 10000) 
     77        _v_total = 0 
     78        _v_transaction = None 
    7479 
    7580        # For each catalog record update metadata 
     
    97102            data[rid] = tuple(mdlist) 
    98103 
     104            # Steeled from ZCatalog 
     105            if threshold is not None: 
     106                # figure out whether or not to commit a subtransaction. 
     107                t = id(transaction.get()) 
     108                if t != _v_transaction: 
     109                    _v_total = 0 
     110                _v_transaction = t 
     111                _v_total = _v_total + 1 
     112                if _v_total > threshold: 
     113                    transaction.savepoint(optimistic=True) 
     114                    catalog._p_jar.cacheGC() 
     115                    _v_total = 0 
     116                    LOG.info('commiting subtransaction') 
     117 
Note: See TracChangeset for help on using the changeset viewer.