我在Google App Engine上做了一个教程,我收到了这个错误:
ERROR 2016-08-27 17:41:18,545 webapp2.py:1552] __init__() got an unexpected keyword argument 'require'
我不知道它的要求是什么或含义。请指教。谢谢。
当我打电话时会发生这种情况:
控制器:
json_response = Users.add_new_user(name, email, password)
型号:
class Users(db.Model):
name = db.StringProperty(required = True)
email = db.StringProperty(required = True)
password = db.StringProperty(require = True)
confirmation_code = db.StringProperty(required = True)
confirmed_email = db.BooleanProperty(default = False)
@classmethod
def check_if_exists(cls, email):
return cls.query(cls.email == email).get()
@classmethod
def add_new_user(cls, name, email, password):
user = cls.check_if_exists(email)
if not user:
random_bytes = urandom(64)
salt = b64encode(random_bytes).decode('utf-8')
hashed_password = salt + sha256(salt + password).hexdigest()
confirmation_code = str(uuid.uuid4().get_hex())
new_user_key = cls(
name=name,
email=email,
password=hashed_password,
confirmation_code=confirmation_code
).put()
print(new_user_key)
return {
'created': True,
'user_id': new_user_key.id(),
'confirmation_code':confirmation_code
}
else:
return {
'created': False,
'title': 'This email is already in use',
'message': 'Please log in if this is your email account. '
}
答案 0 :(得分:2)
你有一个拼写错误:require
而不是required
:
password = db.StringProperty(require = True)