本文整理汇总了Python中pyramid.httpexceptions.HTTPFound.headers方法的典型用法代码示例。如果您正苦于以下问题:Python HTTPFound.headers方法的具体用法?Python HTTPFound.headers怎么用?Python HTTPFound.headers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.httpexceptions.HTTPFound
的用法示例。
在下文中一共展示了HTTPFound.headers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __call__
# 需要导入模块: from pyramid.httpexceptions import HTTPFound [as 别名]
# 或者: from pyramid.httpexceptions.HTTPFound import headers [as 别名]
def __call__(self):
""" login view callable """
# convenient method to set Cache-Control and Expires headers
self.request.response.cache_expires = 0
dbsession = DBSession()
params = self.request.params
login_url = route_url('login', self.request)
message = ''
# playerid, password from cookie
playerid = ''
password = ''
passwordFromCookie = False
lc = self.request.cookies.get('cis_login_credentials', '')
if lc:
lc = lc.split('|')
if len(lc) == 3:
passwordFromCookie = True
playerid = lc[0]
password = lc[1]
activeUser = User()
activeUser.playerid = playerid
activeUser.password = password
user = None
errors = {}
passwordOk = False
referrer = self.request.url
if referrer == login_url:
referrer = '/'
came_from = self.request.params.get('came_from', referrer)
url = came_from
logged_in = authenticated_userid(self.request)
headers = ''
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:
#.........这里部分代码省略.........