5

我将我的 httplib2 目录复制到我的 GAE 项目中,现在我收到以下错误:

line 64, in <module> _ssl_wrap_socket = ssl.wrap_socket

这是 Google App Engine 的问题,还是我以某种方式错误地安装了我的 httplib2?

完整的错误转储,作为请求(它很大!):

--> --> -->
Traceback (most recent call last):
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 4053, in _HandleRequest
    self._Dispatch(dispatcher, self.rfile, outfile, env_dict)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 3977, in _Dispatch
    base_env_dict=env_dict)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 588, in Dispatch
    base_env_dict=base_env_dict)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 3050, in Dispatch
    self._module_dict)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2954, in ExecuteCGI
    reset_modules = exec_script(handler_path, cgi_path, hook)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2834, in ExecuteOrImportScript
    exec module_code in script_module.__dict__
  File "C:\Users\quaunaut\Documents\Aptana Studio 3 Workspace\qushoutout\src\main.py", line 25, in <module>
    import twitter as twitter
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 1505, in Decorate
    return func(self, *args, **kwargs)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2450, in load_module
    return self.FindAndLoadModule(submodule, fullname, search_path)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 1505, in Decorate
    return func(self, *args, **kwargs)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2339, in FindAndLoadModule
    description)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 1505, in Decorate
    return func(self, *args, **kwargs)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2282, in LoadModuleRestricted
    description)
  File "C:\Users\quaunaut\Documents\Aptana Studio 3 Workspace\qushoutout\src\twitter.py", line 65, in <module>
    import oauth2 as oauth
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 1505, in Decorate
    return func(self, *args, **kwargs)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2450, in load_module
    return self.FindAndLoadModule(submodule, fullname, search_path)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 1505, in Decorate
    return func(self, *args, **kwargs)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2339, in FindAndLoadModule
    description)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 1505, in Decorate
    return func(self, *args, **kwargs)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2282, in LoadModuleRestricted
    description)
  File "C:\Users\quaunaut\Documents\Aptana Studio 3 Workspace\qushoutout\src\oauth2\__init__.py", line 32, in <module>
    import httplib2
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 1505, in Decorate
    return func(self, *args, **kwargs)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2450, in load_module
    return self.FindAndLoadModule(submodule, fullname, search_path)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 1505, in Decorate
    return func(self, *args, **kwargs)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2339, in FindAndLoadModule
    description)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 1505, in Decorate
    return func(self, *args, **kwargs)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2282, in LoadModuleRestricted
    description)
  File "C:\Users\quaunaut\Documents\Aptana Studio 3 Workspace\qushoutout\src\httplib2\__init__.py", line 64, in <module>
    _ssl_wrap_socket = ssl.wrap_socket
AttributeError: 'module' object has no attribute 'wrap_socket'

还是有这个问题。关于我能想到的唯一可能导致此问题的原因是我的机器运行 Python 2.7;是否有可能导致问题?

4

3 回答 3

4

作为一种解决方法:

您可以使用 Google App Engine SDK 1.4.3(这看起来像 1.5.0 回归)。

或者强制 httplib2 在 httplib.FakeSocket 上回退:

import sys
sys.modules['ssl'] = None
import httplib2

那里填写了一个新问题: http ://code.google.com/p/googleappengine/issues/detail?id=5064

它看起来已经在 httplib2 端修复: http ://code.google.com/p/httplib2/source/detail?r=cf721c1693a68e9438899be3d78acccae6ab0e30#

于 2011-05-17T08:51:01.803 回答
2

AppEngine 沙箱不允许访问套接字 API,为了让 http 库在 GAE 上工作,它必须包装 urllib(它反过来包装 url_fetch API)。

编辑看起来 httplib2应该可以工作,所以我想你只需要确保你的路径设置正确。

看到这个问题

于 2011-05-15T21:21:05.223 回答
0

博客声称修复了 GAE 问题。我还没有尝试过,但听起来不错。

于 2011-06-10T15:39:28.230 回答