我是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