开发者

Google App Engine interactive console using the Terminal

Following instructions on this page, Accessing the datastore remotely with remote_api:

I edited app.yaml to include these lines:

builtins:
- remote_api: on

I opened up a Terminal:

$ cd /path/to/app
$ python2.5 /usr/local/google_appengine/remote_api.shell.py\
            -s localhost:8082 -p /_ah/remote_api

At the root of my app folder structure, I have a module named foobar.py, as well as a package named data_models. After gaining access to the remote_api Python interpreter, I t开发者_如何转开发ry the following lines:

import foobar
import data_models

But I get an error:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
ImportError: No module named foobar

Traceback (most recent call last):
  File "<console>", line 1, in <module>
ImportError: No module named data_models

How do I access the interactive console through the Terminal? Am I missing something? The same thing happens even if I login to the cloud server:

$ python2.5 /usr/local/google_appengine/remote_api.shell.py\
            -s my-app.appspot.com -p /_ah/remote_api


remote_api just makes it possible to make RPC calls from a local task to a remote instance of an App Engine app. The Python console itself is still local, and everything you do executes locally. That means that any modules you try and import must exist on your local machine, somewhere your Python instance can find them - probably by adding your app's directory to PYTHONPATH, like this:

$ PYTHONPATH=/my/app/dir python2.5 /usr/local/google_appengine/remote_api.shell.py\
        -s my-app.appspot.com -p /_ah/remote_api


I added the following lines to my .bash_profile so that I won't have to edit PYTHONPATH every time I fire up the Terminal.

PYTHONPATH = "/path/to/app"
export PYTHONPATH


It seems that the remote_api is in a different path than your app so it curpwd is that of the remote_api so your app's code is not available

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜