开发者

Google App Engine & Django Sandbox: Shell and Web seem to be using different datastores?

开发者 https://www.devze.com 2022-12-26 19:33 出处:网络
I\'m new to both Django and Google App Engine, and am using a sandbox in OSX10.6 with the GoogleAppEngineLauncher. I\'ve got a basic \"bookstore\" application running from the tutorial in the OReilly

I'm new to both Django and Google App Engine, and am using a sandbox in OSX10.6 with the GoogleAppEngineLauncher. I've got a basic "bookstore" application running from the tutorial in the OReilly "Programming Google App Engine" book.

Here's the bug: If I add a new object to the datastore through the web interface, then it's readable through the web interface, but does not appear to exist if I query the datastore through the shell开发者_Python百科. Vice versa: If I add an object in the shell, then I can read it from the shell, but it doesn't appear in the web interface.

A related curio: All data vanishes from both datastores when I reboot my computer.

Any thoughts or theories would be welcome. Thanks!

=T=


If you use the remote API shell and point it at the instance you're running on your machine, you should get the same datastore. It's unclear how you're accessing your app via "the shell", but it seems that you're creating a second instance to do so.

The data vanishes from the datastore when you reboot your machine because by default the datastore file is created in /tmp; you can specify another location (one that the system doesn't clean for you on reboot) for it when you run dev_appserver.py.


That's right, python manage.py will get you to another instance of the app (and another datastore) than the Launcher. If you'd like a command-line interface with your application, see How do I activate the Interactive Console on App Engine?, or run the dev server solely from python manage.py runserver rather than the Launcher and continue to use manage.py shell.

I've been bitten by the same datastore deletion. App Engine, for some reason, needs to close shop carefully -- you have to hit "stop" (or hit ctrl-c if running from the dev_appserver.py command, typically on linux) to have the datastore save properly to disk. If you turn off the computer before properly closing out, the datastore will be deleted.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号