Package pyamf :: Package adapters :: Module _google_appengine_ext_db
[hide private]
[frames] | no frames]

Module _google_appengine_ext_db

source code

Google App Engine adapter module.

Sets up basic type mapping and class mappings for using the Datastore API in Google App Engine.


See Also: Datastore API on Google App Engine (external)

Since: 0.3.1

Classes [hide private]
  ModelStub
This class represents a db.Model or db.Expando class as the typed object is being read from the AMF stream.
  GAEReferenceCollection
This helper class holds a dict of klass to key/objects loaded from the Datastore.
  DataStoreClassAlias
This class contains all the business logic to interact with Google's Datastore API's.
Functions [hide private]
Instance of GAEReferenceCollection
getGAEObjects(context)
Returns a reference to the gae_objects on the context.
source code
Instance of klass.
loadInstanceFromDatastore(klass, key, codec=None)
Attempt to load an instance from the datastore, based on klass and key.
source code
 
writeGAEObject(self, object, *args, **kwargs)
The GAE Datastore creates new instances of objects for each get request.
source code
 
install_gae_reference_model_hook(mod)
Called when pyamf.amf0 or pyamf.amf3 are imported.
source code

Imports: db, polymodel, datetime, pyamf, imports, util


Function Details [hide private]

getGAEObjects(context)

source code 

Returns a reference to the gae_objects on the context. If it doesn't exist then it is created.

Parameters:
  • context (Instance of pyamf.BaseContext) - The context to load the gae_objects index from.
Returns: Instance of GAEReferenceCollection
The gae_objects index reference.

Since: 0.4.1

loadInstanceFromDatastore(klass, key, codec=None)

source code 

Attempt to load an instance from the datastore, based on klass and key. We create an index on the codec's context (if it exists) so we can check that first before accessing the datastore.

Parameters:
  • klass (Sub-class of db.Model or db.Expando) - The class that will be loaded from the datastore.
  • key (str) - The key which is used to uniquely identify the instance in the datastore.
  • codec (Instance of pyamf.BaseEncoder or pyamf.BaseDecoder) - The codec to reference the gae_objects index. If supplied,The codec must have have a context attribute.
Returns: Instance of klass.
The loaded instance from the datastore.

Since: 0.4.1

writeGAEObject(self, object, *args, **kwargs)

source code 

The GAE Datastore creates new instances of objects for each get request. This is a problem for PyAMF as it uses the id(obj) of the object to do reference checking.

We could just ignore the problem, but the objects are conceptually the same so the effort should be made to attempt to resolve references for a given object graph.

We create a new map on the encoder context object which contains a dict of object.__class__: {key1: object1, key2: object2, .., keyn: objectn}. We use the datastore key to do the reference checking.

Since: 0.4.1

install_gae_reference_model_hook(mod)

source code 

Called when pyamf.amf0 or pyamf.amf3 are imported. Attaches the writeGAEObject method to the Encoder class in that module.

Parameters:
  • mod - The module imported.

Since: 0.4.1