How to use the transaction._transaction.Transaction function in transaction

To help you get started, we’ve selected a few transaction examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Nexedi / erp5 / product / TIDStorage / transaction_transaction.py View on Github external
# last exception value.
      raise exception[0], exception[1], exception[2]
    else:
      raise
  else:
    if has_storages:
      # Now that everything has been commited, all exceptions relative to added
      # code must be swalowed (but still reported) to avoid confusing transaction
      # system.
      try:
        tid_storage.commit(getFilestorageToTIDMapping(self._resources))
      except:
        LOG('TIDStorage _commitResources', WARNING, 'Exception in commit phase', error=sys.exc_info())
  return result
 
Transaction._commitResources = _commitResources
github Nexedi / erp5 / product / TIDStorage / transaction_transaction.py View on Github external
"""
      Inform TIDStorage connection tracking that commit was aborted.
    """
    self._send_command('abort')
    self._buffered_socket.flush()

  def _send_command(self, command):
    """
      Every command must be followed by an identifier.
      This identifier is used to track transactions, so the same identifier
      must not be used twice at the same time, but can be reused later.
    """
    self._field_exchange.send_field(command)
    self._field_exchange.send_field('%s_%x' % (getZopeId(), thread.get_ident()))

original__commitResources = Transaction._commitResources
def _commitResources(self, *args, **kw):
  """
    Hook Transaction's _commitResources.

    Before:
     - Initialise TIDClient if needed
     - Check if there is any storage we are interested in in current commit
     - If so, issue a begin
    
    After (2 cases):
     - original__commitResources raised:
       - Issue an abort
     - otherwise:
       - Issue a commit

    Note to editors: Prevent your code from raising anything ! This method
github zenoss / ZenPacks.zenoss.OpenStackInfrastructure / ZenPacks / zenoss / OpenStackInfrastructure / zenpacklib.py View on Github external
def _close(self):
            if hasattr(self, '_transaction_abort'):
                Transaction.abort = self._transaction_abort

            super(TestCase, self)._close()
github zopefoundation / Zope / lib / python / transaction / _manager.py View on Github external
def begin(self):
        tid = thread.get_ident()
        txn = self._txns.get(tid)
        if txn is not None:
            txn.abort()
        synchs = self._synchs.get(tid)
        if synchs is not None:
            synchs = synchs.as_list()
        txn = self._txns[tid] = Transaction(synchs, self)
        return txn
github zopefoundation / Zope / lib / python / transaction / _manager.py View on Github external
def get(self):
        tid = thread.get_ident()
        txn = self._txns.get(tid)
        if txn is None:
            synchs = self._synchs.get(tid)
            if synchs is not None:
                synchs = synchs.as_list()
            txn = self._txns[tid] = Transaction(synchs, self)
        return txn
github zopefoundation / Zope / lib / python / transaction / _manager.py View on Github external
def get(self):
        if self._txn is None:
            self._txn = Transaction(self._synchs.as_list(), self)
        return self._txn
github zenoss / ZenPacks.zenoss.ZenPackLib / zenpacklib.py View on Github external
def _close(self):
            if hasattr(self, '_transaction_abort'):
                Transaction.abort = self._transaction_abort

            super(TestCase, self)._close()