App Engine 本地数据存储区内容不持久

App Engine 本地数据存储区内容不持久

问题描述:

我正在使用 web.py 和 GAE(Windows 7、Python27)运行一些基本的测试代码.该表单允许将消息发布到数据存储.当我停止应用程序并再次运行它时,之前发布的所有数据都消失了.使用管理员(http://localhost:8080/_ah/admin/datastore)手动添加实体也有同样的问题.

I'm running some basic test code, with web.py and GAE (Windows 7, Python27). The form enables messages to be posted to the datastore. When I stop the app and run it again, any data posted previously has disappeared. Adding entities manually using the admin (http://localhost:8080/_ah/admin/datastore) has the same problem.

我尝试使用额外标志在应用程序设置中设置路径:

I tried setting the path in the Application Settings using Extra flags:

--datastore_path=D:/path/to/app/

(不确定那里的语法).它没有效果.我在我的计算机上搜索了 *.datastore,也找不到任何文件,这似乎很可疑,尽管在应用程序运行期间数据显然存储在某处.

(Wasn't sure about syntax there). It had no effect. I searched my computer for *.datastore, and couldn't find any files, either, which seems suspect, although the data is obviously being stored somewhere for the duration of the app running.

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()

更新:当我通过命令行运行它时,我得到以下信息:

UPDATE: When I run it via command line, I get the following:

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:usersamyappdatalocal	empdev_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

提示数据存储...没有正确安装?

Suggesting that the datastore... didn't install properly?

从 1.6.4 开始,我们停止在每次写入后保存数据存储.在模拟在 High Replication 数据存储中找到的事务模型时,此方法不起作用(您将丢失最后几个写入).这也是非常低效的.我们更改了它,以便数据存储开发存根刷新所有写入并在关闭时保存其状态.听起来 dev_appserver 没有正确关闭.你应该看到:

As of 1.6.4, we stopped saving the datastore after every write. This method did not work when simulating the transactional model found in the High Replication Datastore (you would lose the last couple writes). It is also horribly inefficient. We changed it so the datastore dev stub flushes all writes and saves its state on shut down. It sounds like the dev_appserver is not shutting down correctly. You should see:

应用所有待处理的事务并保存数据存储

Applying all pending transactions and saving the datastore

在关闭服务器时的日志中(请参阅源代码源代码).如果不这样做,则意味着 dev_appserver 没有完全关闭(使用 TERM 信号或 KeyInterrupt).

in the logs when shutting down the server (see source code and source code). If you don't, it means that the dev_appserver is not being shut down cleanly (with a TERM signal or KeyInterrupt).