查询 GAE 数据存储返回属性类型而不是值
我已将数据存储在 gae 数据存储中,但是当我查询数据并引用属性时,我似乎获得了对对象的引用,而不是属性的值。
class ClassDefinitions(db.Model):
class_name = db.StringProperty
class_definition = db.TextProperty
class FlexEntityAdminHandler(webapp.RequestHandler):
def get(self):
query = db.GqlQuery("SELECT * FROM ClassDefinitions")
definitions = query.fetch(1000, 0)
for definition in definitions:
logging.info("Name: %s", definition.class_name)
logging.info("Def: %s", definition.class_definition)
当我引用definition.class_name时,我得到:
<class 'google.appengine.ext.db.StringProperty'>
而不是我存储的值。我知道它会被存储,因为每次添加新条目时,查询结果数都会增加 1。有谁知道我做错了什么?
I have stored data in the gae datastore, but when I query the data and reference the properties I seem to be getting a reference to the object rather than the value of the attribute.
class ClassDefinitions(db.Model):
class_name = db.StringProperty
class_definition = db.TextProperty
class FlexEntityAdminHandler(webapp.RequestHandler):
def get(self):
query = db.GqlQuery("SELECT * FROM ClassDefinitions")
definitions = query.fetch(1000, 0)
for definition in definitions:
logging.info("Name: %s", definition.class_name)
logging.info("Def: %s", definition.class_definition)
When I reference definition.class_name I get:
<class 'google.appengine.ext.db.StringProperty'>
Instead of the value that I stored. I know that it is getting stored because each time I add a new entry the number of results from the query increases by 1. Does anyone know what I'm doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建模型时,您需要创建属性类型类的实际实例:(
注意
()
。)When creating the model, you need to create actual instances of the property type classes:
(Note the
()
.)