google.appengine.ext.bulkload.bulkload_deprecated module


DEPRECATED mix-in handler for bulk loading data into an application.

Please use the new bulkloader.


class google.appengine.ext.bulkload.bulkload_deprecated.BulkLoadsource

Bases: google.appengine.ext.webapp._webapp25.RequestHandler

A handler for bulk load requests.

This class contains handlers for the bulkloading process. One for GET to provide cookie information for the upload script, and one handler for a POST request to upload the entities.

In the POST request, the body contains the data representing the entities’ property values. The original format was a sequences of lines of comma-separated values (and is handled by the Load method). The current (version 1) format is a binary format described in the Tools and Libraries section of the documentation, and is handled by the LoadV1 method).


Renders an information page with the POST endpoint and cookie flag.


uri – a string containing the request URI


A string with the contents of the info page to be displayed


Yields a tuple of a line number and row for each row of the CSV data.


reader – a csv reader for the input data.

Load(kind, data)source

Parses CSV data, uses a Loader to convert to entities, and stores them.

On error, fails fast. Returns a “bad request” HTTP response code and includes the traceback in the output.

  • kind – a string containing the entity kind that this loader handles

  • data – a string containing the CSV data to load


response code: integer HTTP response code to return output: string containing the HTTP response body

Return type

tuple (response code, output) where

LoadEntities(iter, loader, key_format=None)source

Generates entities and loads them into the datastore. Returns a tuple of HTTP code and string reply.

  • iter – an iterator yielding pairs of a line number and row contents.

  • key_format – a format string to convert a line number into an entity id. If None, then entity ID’s are automatically generated.


Handle a GET. Just show an info page.


Handle a POST. Reads CSV data, converts to entities, and stores them.

class google.appengine.ext.bulkload.bulkload_deprecated.Loader(kind, properties)source

Bases: object

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.

CreateEntity(values, key_name=None)source

Creates an entity from a list of property values.

  • values – list/tuple of str

  • key_name – if provided, the name for the (single) resulting Entity


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.


AssertionError if the number of values doesn’t match the number – of properties in the properties map.


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 [].


entity – datastore.Entity


datastore.Entity or list of datastore.Entity

static RegisteredLoaders()source

Returns a list of the Loader instances that have been created.


Return the entity kind that this Loader handes.

google.appengine.ext.bulkload.bulkload_deprecated.Validate(value, type)source

Checks that value is non-empty and of the right type.

Raises ValueError if value is None or empty, TypeError if it’s not the given type.

  • value – any value

  • type – a type or tuple of types


Starts bulk upload.

Raises TypeError if not, at least one Loader instance is given.


loaders – One or more Loader instance.