使用GAE远程API从本地主机调试 - 连接为时已晚?(Using GAE remote api f

2019-09-22 23:50发布

尝试使用谷歌App Engine的remote_api ,这样我们就可以通过IDE做行由行调试。

远程API起初的伟大工程。 该应用程序能够成功地从数据库中检索信息。 当wepapp响应客户端浏览器中出现的错误。

编码:

这非常类似于App Engine的在给出的示例文件 :

from model import My_Entity
from google.appengine.ext.remote_api import remote_api_stub

# Test database calls
def get(w_self):
    remote_api_stub.ConfigureRemoteApi(None, '/_ah/remote_api', auth_func, 'myapp.appspot.com')

    t_entity = My_Entity.get_by_key_name('the_key')

    w_self.response.set_status(200)

    # The error occurs AFTER this code executes, when webapp actually responds to the browser

错误回溯:

错误似乎涉及到Blob存储区。

是远程API初始化来不及到代码?

... web应用程序后所做的事与通过本地主机服务器的Blob存储区? 然后远程API可能会被重新定向的服务器,而不是其中的webapp期待它成为本地主机调试服务器请求到Blob存储区?

Traceback (most recent call last):
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2795, in _HandleRequest
    login_url)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 3622, in CreateImplicitMatcher
    get_blob_storage)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_blobstore.py", line 420, in CreateUploadDispatcher
    return UploadDispatcher()
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_blobstore.py", line 307, in __init__
    get_blob_storage())
  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'

应在远程API可以在代码中其他地方初始化?

抑或这个问题有别的办法吗?

非常感谢!

Answer 1:

为了得到这个工作,你可以使用测试平台的帮助下,开始被丢失的存根:

ADDRESS=....
remote_api_stub.ConfigureRemoteApi(None, '/_ah/remote_api', auth_func, ADDRESS)

# First, create an instance of the Testbed class.
myTestBed = testbed.Testbed()

# Then activate the testbed, which prepares the service stubs for use.
myTestBed.activate()

# Next, declare which service stubs you want to use.
myTestBed.init_blobstore_stub()
myTestBed.init_logservice_stub()


文章来源: Using GAE remote api for debugging from localhost - Connecting too late?