original_docstring: Commits the current txn.
  
      This function hands off the responsibility of calling _Apply to the owning
      TransactionManager.
  
      Returns:
        The cost of the transaction.
      
docstring: Commits the current txn.
  This function hands off the responsibility of calling _Apply to the owning
  TransactionManager.
docstring_tokens: Commits the current txn . This function hands off the responsibility of calling _Apply to the owning TransactionManager .
code: def Commit(self):
      """Commits the current txn.
  
      This function hands off the responsibility of calling _Apply to the owning
      TransactionManager.
  
      Returns:
        The cost of the transaction.
      """
      try:
  
        trackers = self._GetAllTrackers()
        empty = True
        for tracker in trackers:
          snapshot = tracker._GrabSnapshot(self._txn_manager)
          empty = empty and not tracker._put and not tracker._delete
  
  
          for entity, insert in tracker._put.itervalues():
            Check(not insert or self.Get(entity.key()) is None,
                  'the id allocated for a new entity was already '
                  'in use, please try again')
  
            old_entity = None
            key = datastore_types.ReferenceToKeyValue(entity.key())
            if key in snapshot:
              old_entity = snapshot[key]
            self._AddWriteOps(old_entity, entity)
  
          for reference in tracker._delete.itervalues():
  
  
            old_entity = None
            key = datastore_types.ReferenceToKeyValue(reference)
            if key in snapshot:
              old_entity = snapshot[key]
              if old_entity is not None:
                self._AddWriteOps(None, old_entity)
  
  
        if empty and not self._actions:
          self.Rollback()
          return datastore_pb.Cost()
  
  
        meta_data_list = [tracker._meta_data for tracker in trackers]
        self._txn_manager._AcquireWriteLocks(meta_data_list)
      except:
  
        self.Rollback()
        raise
  
      try:
  
        for tracker in trackers:
          Check(tracker._meta_data._log_pos == tracker._read_pos,
                'Concurrency exception.',
                datastore_pb.Error.CONCURRENT_TRANSACTION)
  
  
        for tracker in trackers:
          tracker._meta_data.Log(self)
        self._state = self.COMMITED
        self._commit_time_s = time.time()
      except:
  
        self.Rollback()
        raise
      else:
  
        for action in self._actions:
          try:
            apiproxy_stub_map.MakeSyncCall(
                'taskqueue', 'Add', action, api_base_pb.VoidProto())
          except apiproxy_errors.ApplicationError, e:
            logging.warning('Transactional task %s has been dropped, %s',
                            action, e)
        self._actions = []
      finally:
        self._txn_manager._RemoveTxn(self)
  
        self._txn_manager._ReleaseWriteLocks(meta_data_list)
  
  
      self._txn_manager._consistency_policy._OnCommit(self)
      return self._cost
code_tokens: def Commit ( self ) : try : trackers = self . _GetAllTrackers ( ) empty = True for tracker in trackers : snapshot = tracker . _GrabSnapshot ( self . _txn_manager ) empty = empty and not tracker . _put and not tracker . _delete for entity , insert in tracker . _put . itervalues ( ) : Check ( not insert or self . Get ( entity . key ( ) ) is None , 'the id allocated for a new entity was already ' 'in use, please try again' ) old_entity = None key = datastore_types . ReferenceToKeyValue ( entity . key ( ) ) if key in snapshot : old_entity = snapshot [ key ] self . _AddWriteOps ( old_entity , entity ) for reference in tracker . _delete . itervalues ( ) : old_entity = None key = datastore_types . ReferenceToKeyValue ( reference ) if key in snapshot : old_entity = snapshot [ key ] if old_entity is not None : self . _AddWriteOps ( None , old_entity ) if empty and not self . _actions : self . Rollback ( ) return datastore_pb . Cost ( ) meta_data_list = [ tracker . _meta_data for tracker in trackers ] self . _txn_manager . _AcquireWriteLocks ( meta_data_list ) except : self . Rollback ( ) raise try : for tracker in trackers : Check ( tracker . _meta_data . _log_pos == tracker . _read_pos , 'Concurrency exception.' , datastore_pb . Error . CONCURRENT_TRANSACTION ) for tracker in trackers : tracker . _meta_data . Log ( self ) self . _state = self . COMMITED self . _commit_time_s = time . time ( ) except : self . Rollback ( ) raise else : for action in self . _actions : try : apiproxy_stub_map . MakeSyncCall ( 'taskqueue' , 'Add' , action , api_base_pb . VoidProto ( ) ) except apiproxy_errors . ApplicationError , e : logging . warning ( 'Transactional task %s has been dropped, %s' , action , e ) self . _actions = [ ] finally : self . _txn_manager . _RemoveTxn ( self ) self . _txn_manager . _ReleaseWriteLocks ( meta_data_list ) self . _txn_manager . _consistency_policy . _OnCommit ( self ) return self . _cost
short_docstring: Commits the current txn.
short_docstring_tokens: Commits the current txn .
comment: """Commits the current txn.
  
      This function hands off the responsibility of calling _Apply to the owning
      TransactionManager.
  
      Returns:
        The cost of the transaction.
      """