0

我正在尝试在 Google App Engine 上移植代理(Python 代理);当我在开发模式下运行此代码并尝试通过此代理访问任何页面时,我收到以下错误:

INFO     2013-10-09 14:50:56,539 sdk_update_checker.py:245] Checking for updates to the SDK.
INFO     2013-10-09 14:50:57,029 sdk_update_checker.py:289] This SDK release is newer than the advertised release.
INFO     2013-10-09 14:50:57,046 api_server.py:138] Starting API server at: URL
INFO     2013-10-09 14:50:57,058 dispatcher.py:168] Starting module "default" running at:URL
INFO     2013-10-09 14:50:57,060 admin_server.py:117] Starting admin server at:URL
ERROR    2013-10-09 14:51:04,284 webapp2.py:1528] __init__() takes exactly 4 arguments (3 given)
Traceback (most recent call last):
  File "/home/shekhar/appengine/python/google_appengine/lib/webapp2-2.3/webapp2.py", line 1511, in __call__
    rv = self.handle_exception(request, response, e)
  File "/home/shekhar/appengine/python/google_appengine/lib/webapp2-2.3/webapp2.py", line 1505, in __call__
    rv = self.router.dispatch(request, response)
  File "/home/shekhar/appengine/python/google_appengine/lib/webapp2-2.3/webapp2.py", line 1253, in default_dispatcher
    return route.handler_adapter(request, response)
  File "/home/shekhar/appengine/python/google_appengine/lib/webapp2-2.3/webapp2.py", line 1076, in __call__
    handler = self.handler(request, response)
TypeError: __init__() takes exactly 4 arguments (3 given)
INFO     2013-10-09 14:51:04,289 module.py:599] default: "GET / HTTP/1.1" 500 228

代理是代码如下

class ConnectionHandler:
    def __init__(self, connection, address, timeout):
        self.initialize(request, response);
        self.client = connection
        self.client_buffer = ''
        self.timeout = timeout
        self.method, self.path, self.protocol = self.get_base_header()
        if self.method=='CONNECT':
            self.method_CONNECT()
        elif self.method in ('OPTIONS', 'GET', 'HEAD', 'POST', 'PUT',
                             'DELETE', 'TRACE'):
            self.method_others()
        self.client.close()
        self.target.close()
4

1 回答 1

0

您似乎已经定义了一个自定义类并将其用作响应处理程序。但是响应处理程序有一个特定的约定:它们必须接受requestand response,然后调用initialize。这通常是通过继承来完成的webapp2.RequestHandler请参阅有关覆盖__init__的 webapp2 文档。

我不知道您期望如何传递connection,address和参数。timeout也许你的意思是覆盖get()而不是__init__()

于 2013-10-09T12:03:54.477 回答