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 | Public Attributes | Static Public Attributes | List of all members
google.appengine.tools.bulkloader.Exporter Class Reference
Inheritance diagram for google.appengine.tools.bulkloader.Exporter:
google.appengine.tools.bulkloader.DumpExporter

Public Member Functions

def __init__
 
def output_entities
 
def initialize
 
def finalize
 
def sort_key_from_entity
 

Static Public Member Functions

def RegisterExporter
 
def RegisteredExporters
 
def RegisteredExporter
 

Public Attributes

 output_filename
 

Static Public Attributes

 kind = None
 
 calculate_sort_key_from_entity = False
 

Detailed Description

A base class for serializing datastore entities.

To add a handler for exporting an entity kind from your datastore,
write a subclass of this class that calls Exporter.__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 handle_entity.

See the output_entities method for the writing of data from entities.

Constructor & Destructor Documentation

def google.appengine.tools.bulkloader.Exporter.__init__ (   self,
  kind,
  properties 
)
Constructor.

Populates this Exporters's kind and properties map.

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

  properties: list of (name, converter, default) tuples.

  This is used to automatically convert the entities to strings.
  The converter should be a function that takes one argument, a property
  value of the appropriate type, and returns a str or unicode.  The default
  is a string to be used if the property is not present, or None to fail
  with an error if the property is missing.

  For example:
[('name', str, None),
 ('id_number', str, None),
 ('email', str, ''),
 ('user', str, None),
 ('birthdate',
  lambda x: str(datetime.datetime.fromtimestamp(float(x))),
  None),
 ('description', str, ''),
 ]

Member Function Documentation

def google.appengine.tools.bulkloader.Exporter.finalize (   self)
Performs finalization actions after the download completes.
def google.appengine.tools.bulkloader.Exporter.initialize (   self,
  filename,
  exporter_opts 
)
Performs initialization and validation of the output file.

This implementation checks that the input file exists and can be
opened for writing.

Args:
  filename: The string given as the --filename flag argument.
  exporter_opts: The string given as the --exporter_opts flag argument.
def google.appengine.tools.bulkloader.Exporter.output_entities (   self,
  entity_generator 
)
Outputs the downloaded entities.

This implementation writes CSV.

Args:
  entity_generator: A generator that yields the downloaded entities
in key order.
def google.appengine.tools.bulkloader.Exporter.RegisteredExporter (   kind)
static
Returns an exporter instance for the given kind if it exists.
def google.appengine.tools.bulkloader.Exporter.RegisteredExporters ( )
static
Returns a dictionary of the exporter instances that have been created.
def google.appengine.tools.bulkloader.Exporter.RegisterExporter (   exporter)
static
Register exporter and the Exporter instance for its kind.

Args:
  exporter: A Exporter instance.
def google.appengine.tools.bulkloader.Exporter.sort_key_from_entity (   self,
  entity 
)
A value to alter sorting of entities in output_entities entity_generator.

Will only be called if calculate_sort_key_from_entity is true.
Args:
  entity: A datastore.Entity.
Returns:
  A value to store in the intermediate sqlite table. The table will later
  be sorted by this value then by the datastore key, so the sort_key need
  not be unique.

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