App Engine Python SDK  v1.6.9 rev.445
The Python runtime is available as an experimental Preview feature.
Public Member Functions | Static Public Attributes | List of all members
google.appengine.datastore.datastore_rpc.BaseConnection Class Reference
Inheritance diagram for google.appengine.datastore.datastore_rpc.BaseConnection:
google.appengine.datastore.datastore_rpc.Connection google.appengine.datastore.datastore_rpc.TransactionalConnection

Public Member Functions

def __init__
 
def adapter
 
def config
 
def is_pending
 
def get_pending_rpcs
 
def get_datastore_type
 
def wait_for_all_pending_rpcs
 
def check_rpc_success
 
def get
 
def async_get
 
def get_indexes
 
def async_get_indexes
 
def put
 
def async_put
 
def delete
 
def async_delete
 
def begin_transaction
 
def async_begin_transaction
 

Static Public Attributes

int UNKNOWN_DATASTORE = 0
 
int MASTER_SLAVE_DATASTORE = 1
 
int HIGH_REPLICATION_DATASTORE = 2
 
 create_rpc = _create_rpc
 
 make_rpc_call = _make_rpc_call
 
int MAX_RPC_BYTES = 1024
 
int MAX_GET_KEYS = 1000
 
int MAX_PUT_ENTITIES = 500
 
int MAX_DELETE_KEYS = 500
 
int MAX_ALLOCATE_IDS_KEYS = 500
 
int DEFAULT_MAX_ENTITY_GROUPS_PER_RPC = 10
 

Detailed Description

Datastore connection base class.

NOTE: Do not instantiate this class; use Connection or
TransactionalConnection instead.

This is not a traditional database connection -- with App Engine, in
the end the connection is always implicit in the process state.
There is also no intent to be compatible with PEP 249 (Python's
Database-API).  But it is a useful abstraction to have an explicit
object that manages the database interaction, and especially
transactions.  Other settings related to the App Engine datastore
are also stored here (e.g. the RPC timeout).

A similar class in the Java API to the App Engine datastore is
DatastoreServiceConfig (but in Java, transaction state is always
held by the current thread).

To use transactions, call connection.new_transaction().  This
returns a new connection (an instance of the TransactionalConnection
subclass) which you should use for all operations in the
transaction.

This model supports multiple unrelated concurrent transactions (but
not nested transactions as this concept is commonly understood in
the relational database world).

When the transaction is done, call .commit() or .rollback() on the
transactional connection.  If .commit() returns False, the
transaction failed and none of your operations made it to the
datastore; if it returns True, all your operations were committed.
The transactional connection cannot be used once .commit() or
.rollback() is called.

Transactions are created lazily.  The first operation that requires
a transaction handle will issue the low-level BeginTransaction
request and wait for it to return.

Transactions keep track of the entity group.  All operations within
a transaction must use the same entity group.  An entity group
(currently) comprises an app id, a namespace, and a top-level key (a
kind and an id or name).  The first operation performed determines
the entity group.  There is some special-casing when the first
operation is a put() of an entity with an incomplete key; in this case
the entity group is determined after the operation returns.

NOTE: the datastore stubs in the dev_appserver currently support
only a single concurrent transaction.  Specifically, the (old) file
stub locks up if an attempt is made to start a new transaction while
a transaction is already in use, whereas the sqlite stub fails an
assertion.

Constructor & Destructor Documentation

def google.appengine.datastore.datastore_rpc.BaseConnection.__init__ (   self,
  adapter = None,
  config = None,
  _api_version = _DATASTORE_V3 
)
Constructor.

All arguments should be specified as keyword arguments.

Args:
  adapter: Optional AbstractAdapter subclass instance;
default IdentityAdapter.
  config: Optional Configuration object.

Member Function Documentation

def google.appengine.datastore.datastore_rpc.BaseConnection.adapter (   self)
The adapter used by this connection.
def google.appengine.datastore.datastore_rpc.BaseConnection.async_begin_transaction (   self,
  config,
  app 
)
Asynchronous BeginTransaction operation.

Args:
  config: A configuration object or None.  Defaults are taken from
the connection's default configuration.
  app: Application ID.

Returns:
  A MultiRpc object.
def google.appengine.datastore.datastore_rpc.BaseConnection.async_delete (   self,
  config,
  keys,
  extra_hook = None 
)
Asynchronous Delete operation.

Args:
  config: A Configuration object or None.  Defaults are taken from
the connection's default configuration.
  keys: An iterable of user-level key objects.
  extra_hook: Optional function to be called once the RPC has completed.

Returns:
  A MultiRpc object.
def google.appengine.datastore.datastore_rpc.BaseConnection.async_get (   self,
  config,
  keys,
  extra_hook = None 
)
Asynchronous Get operation.

Args:
  config: A Configuration object or None.  Defaults are taken from
the connection's default configuration.
  keys: An iterable of user-level key objects.
  extra_hook: Optional function to be called on the result once the
RPC has completed.

Returns:
  A MultiRpc object.
def google.appengine.datastore.datastore_rpc.BaseConnection.async_get_indexes (   self,
  config,
  extra_hook = None,
  _app = None 
)
Asynchronous get indexes operation.

Args:
  config: A Configuration object or None.  Defaults are taken from
the connection's default configuration.
  extra_hook: Optional function to be called once the RPC has completed.

Returns:
  A MultiRpc object.
def google.appengine.datastore.datastore_rpc.BaseConnection.async_put (   self,
  config,
  entities,
  extra_hook = None 
)
Asynchronous Put operation.

Args:
  config: A Configuration object or None.  Defaults are taken from
the connection's default configuration.
  entities: An iterable of user-level entity objects.
  extra_hook: Optional function to be called on the result once the
RPC has completed.

 Returns:
  A MultiRpc object.

NOTE: If any of the entities has an incomplete key, this will
*not* patch up those entities with the complete key.
def google.appengine.datastore.datastore_rpc.BaseConnection.begin_transaction (   self,
  app 
)
Syncnronous BeginTransaction operation.

NOTE: In most cases the new_transaction() method is preferred,
since that returns a TransactionalConnection object which will
begin the transaction lazily.

Args:
  app: Application ID.

Returns:
  An object representing a transaction or None.
def google.appengine.datastore.datastore_rpc.BaseConnection.check_rpc_success (   self,
  rpc 
)
Check for RPC success and translate exceptions.

This wraps rpc.check_success() and should be called instead of that.

This also removes the RPC from the list of pending RPCs, once it
has completed.

Args:
  rpc: A UserRPC or MultiRpc object.

Raises:
  Nothing if the call succeeded; various datastore_errors.Error
  subclasses if ApplicationError was raised by rpc.check_success().
def google.appengine.datastore.datastore_rpc.BaseConnection.config (   self)
The default configuration used by this connection.
def google.appengine.datastore.datastore_rpc.BaseConnection.delete (   self,
  keys 
)
Synchronous Delete operation.

Args:
  keys: An iterable of user-level key objects.

Returns:
  None.
def google.appengine.datastore.datastore_rpc.BaseConnection.get (   self,
  keys 
)
Synchronous Get operation.

Args:
  keys: An iterable of user-level key objects.

Returns:
  A list of user-level entity objects and None values, corresponding
  1:1 to the argument keys.  A None means there is no entity for the
  corresponding key.
def google.appengine.datastore.datastore_rpc.BaseConnection.get_datastore_type (   self,
  app = None 
)
Tries to get the datastore type for the given app.

This function is only guaranteed to return something other than
UNKNOWN_DATASTORE when running in production and querying the current app.
def google.appengine.datastore.datastore_rpc.BaseConnection.get_indexes (   self)
Synchronous get indexes operation.

Returns:
  user-level indexes representation
def google.appengine.datastore.datastore_rpc.BaseConnection.get_pending_rpcs (   self)
Return (a copy of) the list of currently pending RPCs.
def google.appengine.datastore.datastore_rpc.BaseConnection.is_pending (   self,
  rpc 
)
Check whether an RPC object is currently pending.

Note that 'pending' in this context refers to an RPC associated
with this connection for which _remove_pending() hasn't been
called yet; normally this is called by check_rpc_success() which
itself is called by the various result hooks.  A pending RPC may
be in the RUNNING or FINISHING state.

If the argument is a MultiRpc object, this returns true if at least
one of its wrapped RPCs is pending.
def google.appengine.datastore.datastore_rpc.BaseConnection.put (   self,
  entities 
)
Synchronous Put operation.

Args:
  entities: An iterable of user-level entity objects.

Returns:
  A list of user-level key objects, corresponding 1:1 to the
  argument entities.

NOTE: If any of the entities has an incomplete key, this will
*not* patch up those entities with the complete key.
def google.appengine.datastore.datastore_rpc.BaseConnection.wait_for_all_pending_rpcs (   self)
Wait for all currently pending RPCs to complete.

The documentation for this class was generated from the following file: