Search code examples
pythongoogle-app-enginedjango-nonrel

GAE SDK 1.6.4 dev_appserver datastore flush


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").


Solution

  • 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.