cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE")) session = cookie.get("session") if session is not None: session = session.value user = User.find_cookie(session) form = cgi.FieldStorage() action = form.getfirst("action", "") if action == "publish": text = form.getfirst("text", "") text = html.escape(text) if text and user is not None: Wall.publish(user,text) elif action == "register": login = form.getfirst("login", "") login = html.escape(login) password = form.getfirst("password", "") password = html.escape(password) if User.find(login, password): cookie = User.set_cookie(login) print('Set-cookie: session={}'.format(cookie)) elif User.find(login): print ('¬ведите пароль') else: User.register(login,password) cookie = User.set_cookie(login) print('Set-cookie: session={}'.format(cookie))