google.appengine.ext.ndb.Context

Inherits From: expected_type

Methods

allocate_ids

View source

call_on_commit

View source

Call a callback upon successful commit of a transaction.

If not in a transaction, the callback is called immediately.

In a transaction, multiple callbacks may be registered and will be called once the transaction commits, in the order in which they were registered. If the transaction fails, the callbacks will not be called.

If the callback raises an exception, it bubbles up normally. This means:

  • If the callback is called immediately, any exception it raises will bubble up immediately.
  • If the call is postponed until commit, remaining callbacks will be skipped and the exception will bubble up through the transaction() call. However, the transaction is already committed at that point.

clear_cache

View source

Clears the in-memory cache.

NOTE: This does not affect memcache.

default_cache_policy

View source

Default cache policy.

This defers to _use_cache on the Model class.

Args
key Key instance.

Returns
A bool or None.

default_datastore_policy

View source

Default Datastore policy.

This defers to _use_datastore on the Model class.

Args
key Key instance.

Returns
A bool or None.

default_memcache_policy

View source

Default Memcache policy.

This defers to _use_memcache on the Model class.

Args
key Key instance.

Returns
A bool or None.

default_memcache_timeout_policy

View source

Default Memcache timeout policy.

This defers to _memcache_timeout on the Model class.

Args
key Key instance.

Returns
Memcache timeout to use (integer), or None.

delete

View source

flush

View source

get

View source

Returns a Model instance given the entity key.

It will use the context cache if the cache policy for the given key is enabled.

Args
key Key instance.
**ctx_options Context options.

Returns
A Model instance if the key exists in the datastore; None otherwise.

get_cache_policy

View source

Return the current context cache policy function.

Returns
A function that accepts a Key instance as argument and returns a bool indicating if it should be cached. May be None.

get_datastore_policy

View source

Return the current context datastore policy function.

Returns
A function that accepts a Key instance as argument and returns a bool indicating if it should use the datastore. May be None.

get_indexes

View source

get_memcache_policy

View source

Return the current memcache policy function.

Returns
A function that accepts a Key instance as argument and returns a bool indicating if it should be cached. May be None.

get_memcache_timeout_policy

View source

Return the current policy function for memcache timeout (expiration).

in_transaction

View source

Return whether a transaction is currently active.

iter_query

View source

map_query

View source

memcache_add

View source

memcache_cas

View source

memcache_decr

View source

memcache_delete

View source

memcache_get

View source

An auto-batching wrapper for memcache.get() or .get_multi().

Args
key Key to set. This must be a string; no prefix is applied.
for_cas If True, request and store CAS ids on the Context.
namespace Optional namespace.
deadline Optional deadline for the RPC.

Returns
A Future (!) whose return value is the value retrieved from memcache, or None.

memcache_gets

View source

memcache_incr

View source

memcache_replace

View source

memcache_set

View source

put

View source

set_cache_policy

View source

Set the context cache policy function.

Args
func A function that accepts a Key instance as argument and returns a bool indicating if it should be cached. May be None.

set_datastore_policy

View source

Set the context datastore policy function.

Args
func A function that accepts a Key instance as argument and returns a bool indicating if it should use the datastore. May be None.

set_memcache_policy

View source

Set the memcache policy function.

Args
func A function that accepts a Key instance as argument and returns a bool indicating if it should be cached. May be None.

set_memcache_timeout_policy

View source

Set the policy function for memcache timeout (expiration).

If the function returns 0, it implies the default timeout.

Args
func A function that accepts a key instance as argument and returns an integer indicating the desired memcache timeout. May be None.

transaction

View source

urlfetch

View source