GAE SDK 1.6.4 dev_appserver数据存储刷新 [英] GAE SDK 1.6.4 dev_appserver datastore flush
问题描述
在1.6.3和1.6.4之间有一些变化,关于dev_appserver数据存储刷新到应用程序退出时的磁盘?
我使用的是django-nonrel,在1.6.3和之前,我曾经可以加载一个python shell:
python manage.py shell(manage.py由django-nonrel提供)
然后我可以导入我的模型并接受数据存储,修改实体和退出。
在1.6.4上,我可以这样做,但是当我退出时,更改不会保存到数据存储中。当我将django-nonrel作为WSGI应用运行时,它可以正常保存,并在退出时看到一条消息(应用所有待处理事务并保存数据存储)。
感谢dragonx提供的解决方案和信息。
我从eclipse运行我的devserver,我很惊讶地发现我的数据在升级到1.6.4 $ b $后没有被保存。我在每次web请求后都向数据库添加了一个flush,为此我实现了一个所有请求的基类和重载调度:
developmentServer = False
如果os.environ.get ('SERVER_SOFTWARE','')。startswith('Development'):
developmentServer = True
$ b $ class BaseRequestHandler(webapp2.RequestHandler):
def dispatch(self):
retValue = super(BaseRequestHandler,self).dispatch()
如果developmentServer:
from google.appengine.tools import dev_appserver
dev_appserver.TearDownStubs()
返回retValue
通知发行说明中类似行为的变化,会为我节省两个查找我升级时出错的日子。
Hoping to get a comment from the GAE python team on this one.
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?
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.
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").
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屋!