【发布时间】:2012-09-06 23:42:00
【问题描述】:
使用 Python,我正在尝试连接到我的 AppEngine 应用程序的 remote_api 处理程序,但我不断收到错误消息。我想要做的是设置 remote_api 存根以通过它路由数据库调用并直接访问我的应用程序的数据存储。因此,首先,我导入 remote_api 库,然后在存根模块上调用 ConfigureRemoteApi,并尝试使用对远程数据存储的调用。下面是一些示例代码:
from google.appengine.ext.remote_api import remote_api_stub
def test_remote_api():
# This function is called when I want to use the remote api instead of the local datastore access
remote_api_stub.ConfigureRemoteApi('myapp.appspot.com', '/_ah/remote_api', auth_func, '')
def auth_func:
# This actually returns a tuple with my credentials to skip the console input
return ('username', 'password')
好的,现在,我已经使用 remote_api_shell.py 测试了我的登录信息和应用名称,但我收到如下错误:
File "C:\Program Files(x86)\Google\google_appengine\google\appengine\tools\dev_appserver_blobstore.py", line 79, in GetBlobStorage
return apiproxy_stub_map.apiproxy.GetStub('blobstore').storage
AttributeError: 'RemoteStub' object has no attribute 'storage'
然后我得到一个 404: Not Found 从应用程序,我知道这是错误的,因为从 Web 访问应用程序确实给了我结果。我需要做些什么来设置 remote_api_stub 以免出现此错误?
谢谢!
【问题讨论】:
-
你想达到什么目的?
-
我在我的问题中说明了这一点:“我想要做的是设置 remote_api 存根以通过它路由数据库调用并直接访问我的应用程序的数据存储区。”另外,“我需要做什么来设置 remote_api_stub,这样我就不会收到这个错误?”。如果不清楚,我希望能够从 inside 我的代码使用 remote_api 调用,而不是从 remote_api shell 调用我的应用程序代码。
-
如果我的问题不清楚,我深表歉意。从代码内部使用 remote_api 调用的目的是什么?我认为远程 api 的目的是能够从您的应用程序外部调用您的应用程序代码。
-
这当然是可行的。我有一个项目,其中 zope/plone 可以通过 remote_api 直接写入数据存储。 ConfigureRemoteApi 的第一个参数是 appid,根据下面的答案。
标签: python google-app-engine remoteapi