def RunInTransactionOptions(options, function, *args, **kwargs):








  options = datastore_rpc.TransactionOptions(options)
  if IsInTransaction():
    if options.propagation in (None, datastore_rpc.TransactionOptions.NESTED):

      raise datastore_errors.BadRequestError(
          'Nested transactions are not supported.')
    elif options.propagation is datastore_rpc.TransactionOptions.INDEPENDENT:


      txn_connection = _GetConnection()
      _SetConnection(_thread_local.old_connection)
      try:
        return RunInTransactionOptions(options, function, *args, **kwargs)
      finally:
        _SetConnection(txn_connection)
    return function(*args, **kwargs)

  if options.propagation is datastore_rpc.TransactionOptions.MANDATORY:
    raise datastore_errors.BadRequestError(
      'Requires an existing transaction.')


  retries = options.retries
  if retries is None:
    retries = DEFAULT_TRANSACTION_RETRIES

  _thread_local.old_connection = _GetConnection()

  for _ in range(0, retries + 1):
    new_connection = _thread_local.old_connection.new_transaction(options)
    _SetConnection(new_connection)
    try:
      ok, result = _DoOneTry(new_connection, function, args, kwargs)
      if ok:
        return result
    finally:
      _SetConnection(_thread_local.old_connection)


  raise datastore_errors.TransactionFailedError(
    'The transaction could not be committed. Please try again.')
Change data in the database.
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/api/datastore.py/RunInTransactionOptions--crossover with--dataset/ETHPy150Open shinymud/ShinyMUD/src/shinymud/lib/db.py/DB.update