def create(cls, firstname, lastname, school, password_raw): """ アカウント作成 @param str firstname 名前 @param str lastname 苗字 @param str school 所属学校名 @param str password_raw パスワード @return (bool, User|None) 成功か, ユーザ """ if not (firstname and lastname and school and password_raw): print(u"入力し忘れあるんじゃない?".encode("utf-8")) return False, None # Get the school'key. If it did not exist, quit this function. school_key = School.query(School.name == school).get(keys_only=True) if not school_key: return False, None # Create a user. returun this user. user = cls(firstname=firstname, lastname=lastname, school_key=school_key, password_raw=security.generate_password_hash(password_raw, length=20)) user.put() return True, user