当前位置: 首页>>代码示例>>Python>>正文


Python HTTPFound.cache_control方法代码示例

本文整理汇总了Python中pyramid.httpexceptions.HTTPFound.cache_control方法的典型用法代码示例。如果您正苦于以下问题:Python HTTPFound.cache_control方法的具体用法?Python HTTPFound.cache_control怎么用?Python HTTPFound.cache_control使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyramid.httpexceptions.HTTPFound的用法示例。


在下文中一共展示了HTTPFound.cache_control方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: do_logout

# 需要导入模块: from pyramid.httpexceptions import HTTPFound [as 别名]
# 或者: from pyramid.httpexceptions.HTTPFound import cache_control [as 别名]
    def do_logout(self, request, location):
        """ do the logout """
        # convenient method to set Cache-Control and Expires headers
        request.response.cache_expires = 0

        headers = forget(request)
        response = HTTPFound(location=location, headers=headers)
        response.delete_cookie('cis_account', path="/")
        response.cache_control = 'no-cache'

        request.session.pop_flash('token')
        return response
开发者ID:puittenbroek,项目名称:cister.db,代码行数:14,代码来源:login.py

示例2: __call__

# 需要导入模块: from pyramid.httpexceptions import HTTPFound [as 别名]
# 或者: from pyramid.httpexceptions.HTTPFound import cache_control [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
                    )
开发者ID:puittenbroek,项目名称:cister.db,代码行数:104,代码来源:login.py


注:本文中的pyramid.httpexceptions.HTTPFound.cache_control方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。