本文整理汇总了Python中user.start_session函数的典型用法代码示例。如果您正苦于以下问题:Python start_session函数的具体用法?Python start_session怎么用?Python start_session使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了start_session函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: process_signup
def process_signup():
connection = pymongo.Connection(connection_string, safe=True)
email = bottle.request.forms.get("email")
username = bottle.request.forms.get("username")
password = bottle.request.forms.get("password")
verify = bottle.request.forms.get("verify")
# set these up in case we have an error case
errors = {'username':cgi.escape(username), 'email':cgi.escape(email)}
if (user.validate_signup(username, password, verify, email, errors)):
if (not user.newuser(connection, username, password, email)):
# this was a duplicate
errors['username_error'] = "Username already in use. Please choose another"
return bottle.template("signup", errors)
session_id = user.start_session(connection, username)
print session_id
cookie= user.make_secure_val(session_id)
bottle.response.set_cookie("session",cookie)
bottle.redirect("/welcome")
else:
print "user did not validate"
return bottle.template("signup", errors)
开发者ID:drozas,项目名称:mongodb,代码行数:25,代码来源:blog.py
示例2: process_login
def process_login():
connection = pymongo.Connection(connection_string, safe=True)
username = bottle.request.forms.get("username")
password = bottle.request.forms.get("password")
print ("user submitted ", username, "pass ", password)
userRecord = {}
if (user.validate_login(connection, username, password, userRecord)):
session_id = user.start_session(connection, username)
if (session_id == -1):
bottle.redirect("/internal_error")
cookie = user.make_secure_val(session_id)
bottle.response.set_cookie("session", cookie)
bottle.redirect("/welcome")
else:
return bottle.template("login",
dict(username=cgi.escape(username), password="",
login_error="Invalid Login"))
开发者ID:sumoward,项目名称:Tool,代码行数:26,代码来源:account_management_module.py
示例3: process_login
def process_login():
connection = pymongo.Connection(connection_string, safe=True)
username = bottle.request.forms.get("username")
password = bottle.request.forms.get("password")
print "user submitted ", username, "pass ", password
userRecord = {}
if (user.validate_login(connection, username, password, userRecord)):
session_id = user.start_session(connection, username)
if (session_id == -1):
bottle.redirect("/internal_error")
cookie = user.make_secure_val(session_id)
# Warning, if you are running into a problem whereby the cookie being set here is
# not getting set on the redirct, you are probably using the experimental version of bottle (.12).
# revert to .11 to solve the problem.
bottle.response.set_cookie("session", cookie)
bottle.redirect("/welcome")
else:
return bottle.template("login",
dict(username=cgi.escape(username), password="",
login_error="Invalid Login"))
开发者ID:drozas,项目名称:mongodb,代码行数:28,代码来源:blog.py
示例4: process_login
def process_login():
connection = pymongo.Connection(connection_string, safe=True)
username = bottle.request.forms.get("username")
password = bottle.request.forms.get("password")
userRecord = {}
if user.validate_login(connection, username, password, userRecord):
# looks good. start a new session
session_id = user.start_session(connection, username)
if session_id == -1:
bottle.redirect("/internal_error")
cookie = user.make_secure_val(session_id)
# send the cookie back to the user
bottle.response.set_cookie("session", cookie)
# full round trip here.
bottle.redirect("/welcome")
else:
# not a valid login
return bottle.template("login", dict(username=cgi.escape(username), password="", login_error="Invalid Login"))
开发者ID:Cignite,项目名称:blog-bottle-mongodb,代码行数:25,代码来源:blog.py
示例5: process_signup
def process_signup():
print('signup process')
connection = MongoClient("localhost", 27017)
email = bottle.request.forms.get("email").strip()
username = bottle.request.forms.get("username").strip()
password = bottle.request.forms.get("password").strip()
verify = bottle.request.forms.get("verify").strip()
print(email,username,password,verify)
# set these up in case we have an error case
errors = {'username': cgi.escape(username), 'email': cgi.escape(email)}
print('er:', errors)
if (user.validate_signup(username, password, verify, email, errors)):
print('here1')
if (not user.newuser(connection, username, password, email)):
# this was a duplicate
print('dup')
errors['username_error'] = "Username already in use. Please choose another"
return bottle.template("signup", errors)
session_id = user.start_session(connection, username)
print ('sessionid', session_id)
cookie = user.make_secure_val(session_id)
bottle.response.set_cookie("session", cookie)
#cook = bottle.request.get_cookie('session')
#print('cook', cook)
#print('user', username)
#username = bottle.request.forms.get("username")
return bottle.template("welcome", username=username)
else:
print ("user did not validate")
return bottle.template("signup", errors)
开发者ID:sumoward,项目名称:Tool,代码行数:34,代码来源:recap_questionaire_module.py
示例6: process_login
def process_login():
connection = pymongo.MongoClient(connection_string)
username = bottle.request.forms.get("username")
password = bottle.request.forms.get("password")
print "user submitted ", username, "pass ", password
userRecord = {}
if (user.validate_login(connection, username, password, userRecord)):
session_id = user.start_session(connection, username)
if (session_id == -1):
bottle.redirect("/internal_error")
cookie = user.make_secure_val(session_id)
# не работает с bottle .12, откатитесь на версию .11
bottle.response.set_cookie("session", cookie)
bottle.redirect("/")
else:
return bottle.template("login",
dict(username=cgi.escape(username), password="",
login_error="неверно"))
开发者ID:alexefremo,项目名称:diploma,代码行数:26,代码来源:site.py
示例7: process_signup
def process_signup():
connection = pymongo.MongoClient(connection_string)
email = bottle.request.forms.get("email")
username = bottle.request.forms.get("username")
password = bottle.request.forms.get("password")
verify = bottle.request.forms.get("verify")
# подготовоим объект, если вдруг у нас будут ошибки
errors = {'username':cgi.escape(username), 'email':cgi.escape(email)}
if (user.validate_signup(username, password, verify, email, errors)):
if (not user.newuser(connection, username, password, email)):
# дубликат
errors['username_error'] = "Имя уже используется"
return bottle.template("signup", errors)
session_id = user.start_session(connection, username)
print session_id
cookie= user.make_secure_val(session_id)
bottle.response.set_cookie("session",cookie)
bottle.redirect("/")
else:
print "user did not validate"
return bottle.template("signup", errors)
开发者ID:alexefremo,项目名称:diploma,代码行数:25,代码来源:site.py
示例8: process_login
def process_login():
username = bottle.request.forms.get("username")
password = bottle.request.forms.get("password")
userRecord = {}
if (user.validate_login(username, password, userRecord)):
session_id = user.start_session(userRecord['uid'])
cookie = user.make_secure_val(str(int(session_id)))
bottle.response.set_cookie("session", cookie)
bottle.redirect("/blog/welcome")
else:
return bottle.template("login",
dict(username=cgi.escape(username), password="",
login_error="Invalid Login"))
开发者ID:erlichson,项目名称:cs253,代码行数:15,代码来源:blog.py
示例9: process_signup
def process_signup():
email = bottle.request.forms.get("email")
username = bottle.request.forms.get("username")
password = bottle.request.forms.get("password")
verify = bottle.request.forms.get("verify")
# set these up in case we have an error case
errors = {'username':cgi.escape(username), 'email':cgi.escape(email)}
if (user.validate_signup(username, password, verify, email, errors)):
uid = user.newuser(username, password, email)
if (uid == None):
# this was a duplicate
errors['username_error'] = "Username already in use. Please choose another"
return bottle.template("signup", errors)
session_id = user.start_session(uid)
cookie= user.make_secure_val(str(int(session_id)))
bottle.response.set_cookie("session",cookie)
bottle.redirect("/blog/welcome")
else:
return bottle.template("signup", errors)
开发者ID:erlichson,项目名称:cs253,代码行数:21,代码来源:blog.py
示例10: signup
def signup():
connection = pymongo.Connection(connection_string, safe=True)
username = request.forms.get("username")
password = request.forms.get("password")
# set these up in case we have an error case
errors = {'username_value': cgi.escape(username), 'username': ''}
if user.validate_signup(username, password, errors):
if not user.new_user(connection, username, password):
# this was a duplicate
errors['username_error'] = "Username already in use. Please choose another"
return template("signup", errors)
session_id = user.start_session(connection, username)
print session_id
cookie = user.make_secure_val(session_id)
response.set_cookie("session", cookie)
redirect("/main")
else:
print "user did not validate"
return template("signup", errors)
开发者ID:chromebookbob,项目名称:python2012,代码行数:22,代码来源:routes.py
注:本文中的user.start_session函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论