Write (upsert) a record using a tran.

def write_rec(table_name, objid, data, index_name_values):
    """Write (upsert) a record using a tran."""
    with DatastoreTransaction() as tx:
        entity = tx.get_upsert()

        entity.key.CopyFrom(make_key(table_name, objid))

        prop = entity.property.add()
        prop.name = 'id'
        prop.value.string_value = objid

        prop = entity.property.add()
        prop.name = 'value'
        prop.value.string_value = data

        for name, val in index_name_values:
            prop = entity.property.add()
            prop.name = name
            prop.value.string_value = str(val)