2013-10-09 91 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__()

相關問題