【发布时间】:2012-04-06 18:00:35
【问题描述】:
我正在运行一些基本的测试代码,包括 web.py 和 GAE(Windows 7、Python27)。该表单允许将消息发布到数据存储区。当我停止应用程序并再次运行它时,之前发布的所有数据都消失了。使用管理员手动添加实体(http://localhost:8080/_ah/admin/datastore)也有同样的问题。
我尝试使用额外标志在应用程序设置中设置路径:
--datastore_path=D:/path/to/app/
(不确定那里的语法)。它没有效果。我在我的计算机上搜索 *.datastore,也找不到任何文件,这似乎很可疑,尽管在应用程序运行期间数据显然存储在某个地方。
from google.appengine.ext import db
import web
urls = (
'/', 'index',
'/note', 'note',
'/crash', 'crash'
)
render = web.template.render('templates/')
class Note(db.Model):
content = db.StringProperty(multiline=True)
date = db.DateTimeProperty(auto_now_add=True)
class index:
def GET(self):
notes = db.GqlQuery("SELECT * FROM Note ORDER BY date DESC LIMIT 10")
return render.index(notes)
class note:
def POST(self):
i = web.input('content')
note = Note()
note.content = i.content
note.put()
return web.seeother('/')
class crash:
def GET(self):
import logging
logging.error('test')
crash
app = web.application(urls, globals())
def main():
app.cgirun()
if __name__ == '__main__':
main()
更新: 当我通过命令行运行它时,我得到以下信息:
WARNING 2012-04-06 19:07:31,266 rdbms_mysqldb.py:74] The rdbms API is not available because the MySQLdb library could not be loaded.
INFO 2012-04-06 19:07:31,778 appengine_rpc.py:160] Server: appengine.google.com
WARNING 2012-04-06 19:07:31,783 datastore_file_stub.py:513] Could not read datastore data from c:\users\amy\appdata\local\temp\dev_appserver.datastore
WARNING 2012-04-06 19:07:31,851 dev_appserver.py:3394] Could not initialize images API; you are likely missing the Python "PIL" module. ImportError: No module named _imaging
INFO 2012-04-06 19:07:32,052 dev_appserver_multiprocess.py:647] Running application dev~palimpsest01 on port 8080: http://localhost:8080
INFO 2012-04-06 19:07:32,052 dev_appserver_multiprocess.py:649] Admin console is available at: http://localhost:8080/_ah/admin
提示数据存储...没有正确安装?
【问题讨论】:
-
@AdamCrossland 我不认为这是一个重复,在这个问题中,所有内容都被删除,而在上一个问题中,部分数据被删除。
-
在应用程序午餐时查看日志(在控制台窗格中),您在那里看到任何警告吗?
-
@ShayErlichmen 我已经用命令行运行它的警告更新了我的帖子。绝对是一个线索,但我不知道该怎么办。
-
检查this question中的解决方法我认为它可以帮助您解决问题
标签: python-2.7 google-app-engine persistence google-cloud-datastore