'Generates entities and loads them into the datastore.  Returns
a tuple of HTTP code and string reply.
Args:
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.'

def LoadEntities(self, iter, loader, key_format=None):

    entities = []
    output = []
    for (line_num, columns) in iter:
        key_name = None
        if (key_format is not None):
            key_name = (key_format % line_num)
        if columns:
            try:
                output.append(('\nLoading    from    line    %d...' % line_num))
                new_entities = loader.CreateEntity(columns, key_name=key_name)
                if new_entities:
                    entities.extend(new_entities)
                output.append('done.')
            except:
                stacktrace = traceback.format_exc()
                output.append(('error:\n%s' % stacktrace))
                return (httplib.BAD_REQUEST, ''.join(output))
    datastore.Put(entities)
    return (httplib.OK, ''.join(output))
