GAE SDK 1.6.4 dev_appserver 数据存储刷新 [英] GAE SDK 1.6.4 dev_appserver datastore flush

查看:23
本文介绍了GAE SDK 1.6.4 dev_appserver 数据存储刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望得到 GAE python 团队对此的评论.

Hoping to get a comment from the GAE python team on this one.

1.6.3 和 1.6.4 之间是否在应用退出时将 dev_appserver 数据存储区刷新到磁盘的方式发生了变化?

Has something changed between 1.6.3, 1.6.4 with regards to the way the dev_appserver datastore is flushed to disk on app exit?

我使用的是 django-nonrel,在 1.6.3 和之前,我曾经能够加载一个 python shell:python manage.py shell(manage.py由django-nonrel提供)

I'm using django-nonrel, and on 1.6.3, and before, I used to be able to load up a python shell: python manage.py shell (manage.py is provided by django-nonrel)

然后我可以导入我的模型并访问数据存储、修改实体并退出.

I could then import my models and acceess the datastore, modify entities, and quit.

在 1.6.4 上,我可以这样做,但是当我退出时,更改不会保存到数据存储中.当我将 django-nonrel 作为 WSGI 应用程序运行时,它会正确保存,并且我在退出时看到一条消息(应用所有挂起的事务并保存数据存储").

On 1.6.4, I'm able to do that, but when I quit, changes are not saved to the datastore. When I run django-nonrel as a WSGI app, it saves properly, and I see a message on exit ("Applying all pending transactions and saving the datastore").

推荐答案

感谢 Dragonx 提供的解决方案和信息.我从 eclipse 运行我的 devserver,我很惊讶地看到我的数据在升级到 1.6.4 后没有被保存我在每次 Web 请求后都向数据库添加了刷新,为此我为所有请求实现了一个基类并覆盖调度:

Thanks to dragonx for his solution and info. I run my devserver from eclipse, and I was amazed to see my data not beeing saved after upgrading to 1.6.4 I added a flush to the database after every web request, to do that I implemented a base class for all requests and override dispatch:

developmentServer = False

if os.environ.get('SERVER_SOFTWARE','').startswith('Development'):
    developmentServer = True

class BaseRequestHandler(webapp2.RequestHandler):
    def dispatch(self):
        retValue = super(BaseRequestHandler, self).dispatch()
        if developmentServer:
                from google.appengine.tools import dev_appserver 
                dev_appserver.TearDownStubs()

        return retValue

在发行说明中告知行为的变化,可以节省我两天时间搜索升级中出现的问题.

informing about a change in behavior like that in the release notes, would have saved me two days of searching what went wrong in my upgrade.

这篇关于GAE SDK 1.6.4 dev_appserver 数据存储刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆