开发者

Get entity's property value in different format (GAE-Python)

In google app engine

When i try to get开发者_如何学C propery value by ReferenceProperty element

It return referenced entity value in different format Like:

real stored value "Name" : "demoname"

when i get and print/write: u'demoname

is there any function or way to get value in proper string format.

code:

person model has name property:

o_model = model()

o_model.ref = personmodel reference #db.ReferenceProperty(person)

now i get model entity object:

sro.write(modelobject.ref.name)

output:u'namevalue

wanted:namevalue


If modelobject.ref.name is a StringProperty, then it is "returned by the datastore as a unicode value."

The u' looks like the repr() of a unicode object:

>>> s = u"Unicode String."
>>> print s
Unicode String.
>>> print repr(s)
u'Unicode String.'

Perhaps sro.write() calls repr() or you're storing the repr() of a Unicode string in the datastore?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜