App Engine Python SDK  v1.6.9 rev.445
The Python runtime is available as an experimental Preview feature.
Public Member Functions | Static Public Member Functions | List of all members
google.appengine.ext.bulkload.bulkload_deprecated.Loader Class Reference
Inheritance diagram for google.appengine.ext.bulkload.bulkload_deprecated.Loader:

Public Member Functions

def __init__
 
def kind
 
def CreateEntity
 
def HandleEntity
 

Static Public Member Functions

def RegisteredLoaders
 

Detailed Description

A base class for creating datastore entities from input data.

To add a handler for bulk loading a new entity kind into your datastore,
write a subclass of this class that calls Loader.__init__ from your
class's __init__.

If you need to run extra code to convert entities from the input
data, create new properties, or otherwise modify the entities before
they're inserted, override HandleEntity.

See the CreateEntity method for the creation of entities from the
(parsed) input data.

Constructor & Destructor Documentation

def google.appengine.ext.bulkload.bulkload_deprecated.Loader.__init__ (   self,
  kind,
  properties 
)
Constructor.

Populates this Loader's kind and properties map. Also registers it with
the bulk loader, so that all you need to do is instantiate your Loader,
and the bulkload handler will automatically use it.

Args:
  kind: a string containing the entity kind that this loader handles

  properties: list of (name, converter) tuples.

  This is used to automatically convert the CSV columns into properties.
  The converter should be a function that takes one argument, a string
  value from the CSV file, and returns a correctly typed property value
  that should be inserted. The tuples in this list should match the
  columns in your CSV file, in order.

  For example:
[('name', str),
 ('id_number', int),
 ('email', datastore_types.Email),
 ('user', users.User),
 ('birthdate', lambda x: datetime.datetime.fromtimestamp(float(x))),
 ('description', datastore_types.Text),
 ]

Member Function Documentation

def google.appengine.ext.bulkload.bulkload_deprecated.Loader.CreateEntity (   self,
  values,
  key_name = None 
)
Creates an entity from a list of property values.

Args:
  values: list/tuple of str
  key_name: if provided, the name for the (single) resulting Entity

Returns:
  list of datastore.Entity

  The returned entities are populated with the property values from the
  argument, converted to native types using the properties map given in
  the constructor, and passed through HandleEntity. They're ready to be
  inserted.

Raises:
  AssertionError if the number of values doesn't match the number
of properties in the properties map.
def google.appengine.ext.bulkload.bulkload_deprecated.Loader.HandleEntity (   self,
  entity 
)
Subclasses can override this to add custom entity conversion code.

This is called for each entity, after its properties are populated from
CSV but before it is stored. Subclasses can override this to add custom
entity handling code.

The entity to be inserted should be returned. If multiple entities should
be inserted, return a list of entities. If no entities should be inserted,
return None or [].

Args:
  entity: datastore.Entity

Returns:
  datastore.Entity or list of datastore.Entity
def google.appengine.ext.bulkload.bulkload_deprecated.Loader.kind (   self)
Return the entity kind that this Loader handes.
def google.appengine.ext.bulkload.bulkload_deprecated.Loader.RegisteredLoaders ( )
static
Returns a list of the Loader instances that have been created.

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