我是Python的初學者。我想知道它爲什麼會拋出一個錯誤。 我得到一個錯誤,指出TypeError:client_session()只需要2個參數(給出1) client_session方法返回SecureCookie對象。Python2.7中的錯誤只需要2個參數(1給出)
我這裏有
from werkzeug.utils import cached_property
from werkzeug.contrib.securecookie import SecureCookie
from werkzeug.wrappers import BaseRequest, AcceptMixin, ETagRequestMixin,
class Request(BaseRequest):
def client_session(self,SECRET_KEY1):
data = self.cookies.get('session_data')
print " SECRET_KEY " , SECRET_KEY1
if not data:
print "inside if data"
cookie = SecureCookie({"SECRET_KEY": SECRET_KEY1},secret_key=SECRET_KEY1)
cookie.serialize()
return cookie
print 'self.form[login.name] ', self.form['login.name']
print 'data new' , data
return SecureCookie.unserialize(data, SECRET_KEY1)
#and another
class Application(object):
def __init__(self):
self.SECRET_KEY = os.urandom(20)
def dispatch_request(self, request):
return self.application(request)
def application(self,request):
return request.client_session(self.SECRET_KEY).serialize()
# This is our externally-callable WSGI entry point
def __call__(self, environ, start_response):
"""Invoke our WSGI application callable object"""
return self.wsgi_app(environ, start_response)
我認爲'application()'方法中的'request'應該大寫?此外,這看起來不像python n00b代碼(做得好)。無論我看到這個錯誤,我看到它只有1關閉(需要2,1給出),我通常會發現它與'自我' – TehTris
我曾嘗試使用請求更改r大寫,但它仍然給出相同錯誤 – user2456373