如何在Windows机器上使用remote_api_shell访问appengine数据存储区?

时间:2012-02-10 00:00:20

标签: google-app-engine google-cloud-datastore python-2.7

我正在尝试使用remote_api_shell.py访问我的应用,如http://code.google.com/appengine/articles/remote_api.html中的appengine所述。我在Windows 7中使用python 27并且我能够访问shell - 例如,我远程清除了memcache。我无法使用错误

访问数据存储区
no module found named <module name>

我的目录结构类似

/app.yaml
/main.py
/users/models.py

在Windows shell中,我键入以下内容(根据上述链接的演练)

C:\Users\user>remote_api_shell.py -s appname.appspot.com
App Engine remote_api shell
Python 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)]
The db, users, urlfetch, and memcache modules are imported.
s~appname> import appname
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: No module named appname
s~appname> from google.appengine.ext import db
s~appname> from users.models import *
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: No module named users.models
s~appname> from users import models
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: No module named users

我尝试过几次不同的迭代,但似乎无法访问我的任何数据。我还尝试访问目录/website/models.py中的另一个模型,但也没有成功。有关如何使其工作的任何想法?欢呼声。

2 个答案:

答案 0 :(得分:3)

尝试设置模块搜索路径以包含应用程序所在的目录。这可以通过设置环境变量PYTHONPATH来完成(虽然我忘记了如何在Windows上执行此操作),或者在shell会话中,通过附加到sys.path。

原因是remote_api_shell脚本与您的应用程序位于不同的目录中,因此目录将添加到路径而不是应用程序的目录中,即使后者是当前目录。 / p>

我想你也可以将remote_api_shell.py复制到你的app目录......

答案 1 :(得分:0)

显然,您可以将models.py复制到remote_api_shell.py目录{:^)