开发者

Does db.run_in_transaction return anything?

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?


run_in_transaction returns whatever the called function returned. You need to include the compelte stacktrace and the original code for us to help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜