2013-10-09 57 views
0

我试图在Google App Engine上移植代理(Python代理)当我以开发模式运行这个代码,并试图通过这个代理我收到以下错误访问任何页面:在Google App Engine中移植代理服务器时出错

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

init需要4个参数,并且你传递它3.从那里开始?有一个调试器?看看你可以真正调用它。 –

回答

0

你似乎已经定义一个自定义类,并将其用作响应处理程序。但响应处理人员有特定的合同:他们必须接受requestresponse,然后致电initialize。通常通过继承webapp2.RequestHandler完成。请参阅overriding __init__上的webapp2文档。

我不知道你是如何期待您connectionaddresstimeout参数传递。也许你打算覆盖get()而不是__init__()

相关问题