python - NDB map (回调,produces_cursors=True)

标签 python google-app-engine app-engine-ndb

map() 的 Google AppEngine NDB 文档指出:

"All query options keyword arguments are supported."

但是,我已尝试在 map() 上使用 produces_cursors=True,但我没有取回光标。

map(callback, pass_batch_into_callback=None, merge_future=None, **q_options)

我想使用 map(),因为我可以将回调设置为 tasklet。

https://developers.google.com/appengine/docs/python/ndb/queryclass#kwdargs_options

编辑 - 提供代码示例:

@ndb.tasklet
def callback(user):
    statistics = yield ndb.Key(Statistics, user.key.id()).get_async()
    raise ndb.Return(user, statistics)

result = User.query().map(callback, produces_cursors=True)

最佳答案

该示例似乎有错字——正确的标志是 produce_cursors,而不是 produces_cursors

但是只有在使用迭代器时才能使用游标,而不能使用 map()。查看异步迭代器示例;这需要一些工作,但您绝对可以使用它为每个结果手动创建一个 tasklet。

关于python - NDB map (回调,produces_cursors=True),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14125243/

相关文章:

java - Java 中的 Google App Engine 编码 key

java - 如何将 CSV 数据上传到数据存储

python - 在 Eclipse 中使用 Python 成像库 (PIL)

python - 迭代字典

python - 用两个固定长度的数字对正则表达式进行分组并删除其前导零

python - 如何在 appengine 之外使用 ndb?

google-app-engine - modelname_set 的 Google App Engine ndb 等价物(反向引用属性)

python - 在 Python 中调用 atexit 回调时如何查找退出代码或原因?

java - 持久性 JDO - 如何使用 JDO 查询集合的属性?

google-app-engine - 在 Google App Engine 中使用 NDB 按 BooleanProperty 进行过滤