【发布时间】:2014-04-21 03:30:28
【问题描述】:
在 Python Google App Engine 中存储一个可编辑字符串的最佳方式是什么?我尝试使用 NDB,通过单一路由来创建、读取和更新字符串。但这似乎不起作用:
class Storage(ndb.Model):
content = ndb.StringProperty()
class CreateReadUpdate(webapp2.RequestHandler):
def get(self):
entity = ndb.Key(Storage, 'name').get()
self.response.out.write(entity.content)
def post(self):
content = json.loads(self.request.body).get('content')
entity = ndb.Key(Storage, 'name').get()
if not entity:
entity = Storage(content='')
entity.content = content
entity.put()
不确定如何在此环境中进行调试。所以我不得不问,这里有什么问题?我只想要最简单的 App Engine CRUD。
【问题讨论】:
-
如果有任何东西,您是否检查过数据存储查看器?
标签: python google-app-engine google-cloud-datastore webapp2