def _do_enter(self): if IsInTransaction(): if self.independent: self.conn_stack.append(_PopConnection()) try: return self._do_enter() except: _PushConnection(self.conn_stack.pop()) raise else: # App Engine doesn't support nested transactions, so if there is a nested # atomic() call we just don't do anything. This is how RunInTransaction does it return elif self.mandatory: raise TransactionFailedError("You've specified that an outer transaction is mandatory, but one doesn't exist") options = CreateTransactionOptions( xg=self.xg, propagation=TransactionOptions.INDEPENDENT if self.independent else None ) conn = _GetConnection() self.transaction_started = True new_conn = conn.new_transaction(options) _PushConnection(None) _SetConnection(new_conn) assert(_GetConnection()) # Clear the context cache at the start of a transaction caching.ensure_context() caching._context.stack.push()
def __enter__(self): caching.ensure_context() self.orig_memcache = caching._context.memcache_enabled self.orig_context = caching._context.context_enabled caching._context.memcache_enabled = not self.memcache caching._context.context_enabled = not self.context
def __enter__(self): caching.ensure_context() self.orig_memcache = caching._context.memcache_enabled self.orig_context = caching._context.context_enabled caching._context.memcache_enabled = not self.memcache caching._context.context_enabled = not self.context
def __enter__(self): caching.ensure_context() ctx = caching.get_context() self.orig_memcache = ctx.memcache_enabled self.orig_context = ctx.context_enabled ctx.memcache_enabled = not self.memcache ctx.context_enabled = not self.context
def __enter__(self): caching.ensure_context() ctx = caching.get_context() self.orig_memcache = ctx.memcache_enabled self.orig_context = ctx.context_enabled ctx.memcache_enabled = not self.memcache ctx.context_enabled = not self.context
def _do_enter(cls, state, decorator_args): mandatory = decorator_args.get("mandatory", False) independent = decorator_args.get("independent", False) xg = decorator_args.get("xg", False) # Reset the state state.conn_stack = [] state.transaction_started = False state.original_stack = None if independent: # Unwind the connection stack and store it on the state so that # we can replace it on exit while in_atomic_block(): state.conn_stack.append(_PopConnection()) state.original_stack = copy.deepcopy(caching.get_context().stack) elif in_atomic_block(): # App Engine doesn't support nested transactions, so if there is a nested # atomic() call we just don't do anything. This is how RunInTransaction does it return elif mandatory: raise TransactionFailedError( "You've specified that an outer transaction is mandatory, but one doesn't exist" ) options = CreateTransactionOptions( xg=xg, propagation=TransactionOptions.INDEPENDENT if independent else None) conn = _GetConnection() new_conn = conn.new_transaction(options) _PushConnection(new_conn) assert (_GetConnection()) # Clear the context cache at the start of a transaction caching.ensure_context() caching.get_context().stack.push() state.transaction_started = True
def _do_enter(cls, state, decorator_args): mandatory = decorator_args.get("mandatory", False) independent = decorator_args.get("independent", False) xg = decorator_args.get("xg", False) # Reset the state state.conn_stack = [] state.transaction_started = False state.original_stack = None if independent: # Unwind the connection stack and store it on the state so that # we can replace it on exit while in_atomic_block(): state.conn_stack.append(_PopConnection()) state.original_stack = copy.deepcopy(caching.get_context().stack) elif in_atomic_block(): # App Engine doesn't support nested transactions, so if there is a nested # atomic() call we just don't do anything. This is how RunInTransaction does it return elif mandatory: raise TransactionFailedError("You've specified that an outer transaction is mandatory, but one doesn't exist") options = CreateTransactionOptions( xg=xg, propagation=TransactionOptions.INDEPENDENT if independent else None ) conn = _GetConnection() new_conn = conn.new_transaction(options) _PushConnection(new_conn) assert(_GetConnection()) # Clear the context cache at the start of a transaction caching.ensure_context() caching.get_context().stack.push() state.transaction_started = True