本文整理汇总了Python中pyramid.httpexceptions.HTTPFound.charset方法的典型用法代码示例。如果您正苦于以下问题:Python HTTPFound.charset方法的具体用法?Python HTTPFound.charset怎么用?Python HTTPFound.charset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.httpexceptions.HTTPFound
的用法示例。
在下文中一共展示了HTTPFound.charset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __call__
# 需要导入模块: from pyramid.httpexceptions import HTTPFound [as 别名]
# 或者: from pyramid.httpexceptions.HTTPFound import charset [as 别名]
#.........这里部分代码省略.........
initial_login = not logged_in
storeplayeridPwd = params.get('remember', '')
# if already logged in and requesting this page, redirect to forbidden
if logged_in:
message = 'You do not have the required permissions to see this page.'
return dict(
message=message,
url=url,
came_from=came_from,
password=password,
user=activeUser,
headers=headers,
errors=errors,
logged_in=logged_in,
remember=storeplayeridPwd
)
# check whether we are asked to do an autologin (from pwdreset.py)
autologin = 0 #self.request.session.pop_flash(queue='autologin')
# 'SECURITY RISK'
forcelogin = lc and self.request.params.get('forcelogin', '')
if forcelogin or autologin or 'form.submitted' in params:
if autologin:
autologin = autologin[0].split('|')
playerid = autologin[0]
password = autologin[1] #encrypted
elif forcelogin:
pass
else:
playerid = params['playerid']
# when we get a password from a cookie, we already receive it encrypted. If not, encrypt it here
password = (passwordFromCookie and password) or params['password']
if not password:
errors['password'] = "Enter your password"
else:
# if autologin, we already receive it encrypted. If not, encrypt it here
password = ((forcelogin or autologin) and password) or hashlib.md5(params['password']).hexdigest()
if not playerid:
errors['playerid'] = "Enter your player id"
if playerid and password:
user = dbsession.query(User).filter_by(playerid=playerid).first()
if user:
passwordOk = (user.password == password)
if not user:
message = 'You do not have a CIS account'
elif user.banned:
message = 'Your account has been banned.'
elif not user.activated:
message = 'Your account has not yet been activated'
elif not passwordOk:
message = 'Your account/password do not match'
else:
# READY TO LOGIN, SOME FINAL CHECKS
now = datetime.now()
headers = remember(self.request, user.playerid)
last_login = now.strftime('%Y-%m-%d %H:%M:%S')
user.last_web = last_login
response = HTTPFound()
user.last_login = last_login
response.headers = headers
response.content_type = 'text/html'
response.charset = 'UTF-8'
if storeplayeridPwd:
cookie_val = '%s|%s' % (playerid, password)
response.set_cookie('cis_login_credentials', cookie_val, max_age=timedelta(days=365), path='/')
response.location = came_from
if (not forcelogin) and (not storeplayeridPwd):
response.delete_cookie('cis_login_credentials')
response.cache_control = 'no-cache'
return response
activeUser.playerid = playerid
storeplayeridPwd = self.request.cookies.get('cis_login_credentials') and '1' or ''
return dict(
message=message,
url=url,
came_from=came_from,
password=password,
user=activeUser,
headers=headers,
errors=errors,
logged_in=logged_in,
remember=storeplayeridPwd
)