使用GAE远程API从localhost进行调试 - 连接太晚? [英] Using GAE remote api for debugging from localhost - Connecting too late?

查看:173
本文介绍了使用GAE远程API从localhost进行调试 - 连接太晚?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用Google App Engine的 remote_api ,以便我们可以通过IDE进行逐行调试。



远程api起初效果很好。该应用程序能够成功从数据库中检索信息。这个错误发生在wepapp响应客户端浏览器时。



代码

这与应用程序引擎的文档中给出的示例非常相似:

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

#测试数据库调用
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)

#执行代码后,webapp实际响应浏览器

错误回溯:



这个错误似乎与blobstore有关。

远程ap我在代码中初始化得太晚了?



...在webapp通过localhost服务器完成blobstore的操作之后?那么远程api可能会将请求重定向到服务器中的blobstore,而不是webapp期待它的本地主机调试服务器?

 
Traceback(最近的最后一次调用):
文件C:\程序文件(x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py,第2795行,在_HandleRequest
login_url)
文件C:\程序文件(x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py,第3622行,在CreateImplicitMatcher
get_blob_storage)
在CreateUploadDispatcher $ b中的第420行文件C:\ Program Files(x86)\Google\google_appengine\google\appengine\tools\dev_appserver_blobstore.py $ b返回UploadDispatcher()
文件C:\程序文件(x86)\Google\google_appengine\google\appengine\tools\dev_appserver_blobstore.py,行307,在__init__
get_blob_storage())
GetBlobStorage
中的文件C:\程序文件(x86)\Google\google_appengine\google\appengine\tools\dev_appserver_blobstore.py,第79行返回apiproxy_stub_map.apiproxy.GetStub('blobstore')。storage
AttributeError:'RemoteStub'对象没有'storage'属性

远程api应该在代码的其他地方初始化吗?



或者这个问题与其他东西有关吗?



非常感谢!

解决方案

为了实现这个目标,您可以使用测试平台的帮助来启动存根缺失:

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

#首先,创建一个Testbed类的实例。
myTestBed = testbed.Testbed()

#然后激活测试平台,准备服务存根以供使用。
myTestBed.activate()

#接下来,声明要使用的服务存根。
myTestBed.init_blobstore_stub()
myTestBed.init_logservice_stub()


Trying to use Google App Engine's remote_api so that we can do line-by-line debugging through the IDE.

The remote api works great at first. The application is able to successfully retrieve information from the database. The error occurs when wepapp responds to the client browser.

The Code:

It is very similar to the example given in app engine's documentation:

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

Error Traceback:

The error seems to be related to the blobstore.

Is the remote api initialized too late into the code?

...After webapp has done something with the blobstore through the localhost server? Then the remote api might be re-directing requests to the blobstore in the server instead of the localhost debug server where webapp is expecting it to be?

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'

Should the remote api be initialized somewhere else in the code?

Or does this problem have to do with something else?

Thanks so much!

解决方案

To get this working you can use the help of the testbed to start the stubs that are missing:

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()

这篇关于使用GAE远程API从localhost进行调试 - 连接太晚?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆