db.run_in_transaction 是否返回任何内容?
我正在模仿我在 Taggable Mixin 中找到的交易示例,但它没有表现出来以同样的方式。
def txn():
// statements omitted for brevity
blog_index.put()
new_post = Post(key_name=new_post_key_name, parent=blog_index,
index = new_index, title = new_title,
body = new_body)
new_post.put()
return new_post
def new_post(cls, new_title=None, new_body=None, new_tags=[]):
new_post = db.run_in_transaction(txn)
new_post.tags = new_tags
new_post.put()
在这个例子中,来自txn
的new_post
通过db.run_in_transaction
返回,然后可以用它来做一些事情。但我得到:
TypeError: object is not callable
这让我相信函数 run_in_transaction
被分配给 new_post
变量,而不是从 返回的实际
。new_post
>txn
db.run_in_transaction 可以返回任何内容,例如可调用函数中的值吗?
I'm mimicking a transaction example I found in the Taggable Mixin, but it's not behaving in the same manner.
def txn():
// statements omitted for brevity
blog_index.put()
new_post = Post(key_name=new_post_key_name, parent=blog_index,
index = new_index, title = new_title,
body = new_body)
new_post.put()
return new_post
def new_post(cls, new_title=None, new_body=None, new_tags=[]):
new_post = db.run_in_transaction(txn)
new_post.tags = new_tags
new_post.put()
In this example, the new_post
from txn
is returned through db.run_in_transaction
, then something can be done with it. But I am getting:
TypeError: object is not callable
This leads me to believe the function run_in_transaction
is getting assigned to the new_post
variable, not the actual new_post
returned from txn
.
Can db.run_in_transaction
return anything, like the values from the callable function?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
run_in_transaction
返回被调用函数返回的任何内容。您需要包含完整的堆栈跟踪和原始代码,以便我们提供帮助。run_in_transaction
returns whatever the called function returned. You need to include the compelte stacktrace and the original code for us to help.