Ben Wong Ben Wong - 3 months ago 6
Python Question

Google App Engine Error: __init__() got an unexpected keyword argument 'require'

I'm doing a tutorial on Google App Engine and I"m getting this error:

ERROR 2016-08-27 17:41:18,545 webapp2.py:1552] __init__() got an unexpected keyword argument 'require'


And I don't know what it's asking for or what it means. Please advise. Thanks.

This happens when I call:

Controller:

json_response = Users.add_new_user(name, email, password)


Model:

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. '
}

Answer

You have a typo: require instead of required here:

    password = db.StringProperty(require = True)
Comments