1

我正在尝试使用 bulkuploader 将一些数据上传到我的 App Engine 数据存储区。对于我的一种实体类型,我有一个从另一个计算的属性,所以我真的很想对每个实体进行一些后处理,因为它被导入以进行此计算。我不断看到 post_import_function 转换标签的简短提及,但没有真正全面的文档或示例。

现在,我只是尝试做一个简单的测试来让我的 post_import_function 工作。

我的实体模型:

class TestEntity(db.Model):
    location = db.GeoPtProperty()
    cells = db.StringListProperty() # Computed from location

我的 bulkloader.yaml 文件的相关部分如下所示:

- kind: TestEntity
  [... connector info ...]
  property_map:
    [... transform info for __key__ and location here ...]
  post_import_function: post_transform.post_process_testentity

还有我的 post_process_testentity 函数:

def post_process_testentity(input_dict, entity_instance, bulkload_state):
    entity_instance.cells = [u'Hello there!']
    return entity_instance

当我使用所有这些东西进行数据上传时,我没有收到任何错误(我知道正在输入 post_process_testentity,因为我在其中添加了一些正确运行的打印语句)。关于上传的一切工作,除了我的后期处理功能完全没有效果。当我使用数据查看器时,我的数据存储中没有“Hello there!”。

有人可以帮帮我吗?谢谢!

4

1 回答 1

1

如果其他人也有类似的问题,我可以按照上述方法进行测试。似乎entity_instance在后处理函数中实际上是 type 的google.appengine.api.datastore.Entity,它是dict. 因此,对 post_process_testentity 函数的这种修改起作用了:

def post_process_testentity(input_dict, entity_instance, bulkload_state):
    entity_instance['cells'] = [u'Hello there!']
    return entity_instance

但是,我只是通过打印各种调试消息来解决这个问题。如果这些东西被记录在某个地方,那就太好了。有谁知道我在哪里可以找到这样的文件?

于 2011-02-20T04:33:24.820 回答