开发者

how to Reference the variable via db.run_in_transaction on google-app-engine

this is my code:

class A(db.Model):
    a=db.StringProperty()

class demo(BaseRequestHandler):
    def get(self):
        a=''
        def fn():
            global a
            a=A(a='www')
            a.put()
        db.run_in_transaction(fn)
        rais开发者_高级运维e Exception(a.key())

and the error is :

raise Exception(a.key())
AttributeError: 'str' object has no attribute 'key'

so how to get the right 'a' ,

thanks


Try this:

class demo(BaseRequestHandler):
    def get(self):
        def fn():
            a=A(a='www')
            a.put()
            return a
        a = db.run_in_transaction(fn)
        raise Exception(a.key())
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜